AnsweredAssumed Answered

Chaining ReadOnly and SetVisibility dependencies

Question asked by Andrew Gin on Jan 24, 2018
Latest reply on Sep 21, 2018 by Simon Pountney-Langham

Hi

I understand you can chain dependencies here: http://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_7.9/Architecture/Sugar_Logic/Dependency_… 

I'm using Sugar Enterprise 7.9.2.

 

The following is my dependency:

<?php
$dependencies['Opportunities']['hide_orderform_received_date'] = array(
    'hooks' => array("edit"),
    'trigger' => 'true',
    'triggerFields' => array('sales_stage'),
    'onload' => true,
    //Actions is a list of actions to fire when the trigger is true
    'actions' => array(
        array(
            'name' => 'ReadOnly',
            'params' => array(
                'target' => 'con_orderform_received_c',
                'value' => 'and(contains($sales_stage, "Closed Won"),
                                equal($approved_by_sales_manager_c, true),
                                )',
            ),
        ),
        array(
            'name' => 'SetVisibility',
            'params' => array(
                'target' => 'con_orderform_received_c',
                'value' => 'contains($sales_stage, "Closed Won")',
            ),
        ),
    ),
    'notActions' => array(),
);

So basically I'm chaining ReadOnly and SetVisibility;

  • If the sales stage is "Closed Won", then show the "Order form received date" field
  • If the sales stage is "Closed Won" AND the "approved by sales manager" box is ticked, then make the "Order form received date" read only.

 

However it looks like only one of these can be active at any one time;

In the example, I have ReadOnly first.

When the Opportunity is set to "Closed Won" and the "approved by sales manager" box is ticked:

  • The "Order form received date" field correctly gets set to read only (correct)
  • The "Order form received date" is always visible, regardless of the sales stage (ignoring my SetVisibility dependency) (error)

 

When I put SetVisbility first, the Opportunity is set to "Closed Won" and the "approved by sales manager" box is ticked, the result is:

  • The "Order form received date" is visible only if the sales stage is "Closed Won" (correct)
  • The "Order form received date" is still editable (ignoring my ReadOnly dependency) (error).

 

Are there some restrictions on how depedencies can be combined? The above is not working as intended.

Outcomes