Dependency triggerfields

I have been working with dependency files for some of the functionality (SetOptions, SetRequired, SetValues etc) and generally very useful.

However a couple of questions:

1) Conditional logic : trigger or action value

Depending on the circumstance, I can get dependencies to work putting the logic into either the trigger or the action value. The documentation isn't fully clear on this. Is there a 'best practice' or does it depend on the type of dependency/action being used

2) Trigger when creating a new record only works on initial entry, not when a trigger field changed during entry

So with example below, if I create a new Opportunity (just setting up, not Saving) I get the following behaviour:

Create > set Sales Stage to something other than 'Closed Won', target field not 'Required' = good result

Create > set Sales Stage to 'Closed Won', target field 'Required' = good result

Create > set Sales Stage to 'Closed Won', target field 'Required' > change Sales Stage to something other than 'Closed Won', target field remains 'Required' = not good result

In other words, the watch trigger does not seem to kick in when changes made to the triggerfield(s) during record edit

$dependencies['Opportunities']['required_dep_prthrs'] = array(
'hooks' => array("edit", "view"),
'trigger' => 'isInList($sales_stage, createList("Closed Won"))',
'triggerFields' => array('sales_stage'),
'onload' => true,
//Actions is a list of actions to fire when the trigger is true
'actions' => array(
array(
'name' => 'SetRequired',
//The parameters passed in will depend on the action type set in 'name'
'params' => array(
'target' => 'sym_partner_hours_c',
'value' => 'true',
),
),
),
);

Thanks

Neil

  • Definitely some Dependencies may require the logic to be placed inside the trigger attribute instead of the actions' value.

    They are SetRequired and ReadOnly. All other Dependencies work great when logic is set at the trigger attribute.

    In the case you have to evaluate random updates on trigger fields form Dependencies SetRequired and ReadOnly then you need to setup actions and notActions.

    Find an example:

    $dependencies['Cases']['projeto_origem_c_Editavel'] = array(
    'hooks' => array("view", "edit"),
    'trigger' => 'or(equal($id, ""), and(equal($acc_tipo_cliente_c, "Cliente Final"), isUserInList(createList("SIMM_GER", "SIMM_SUP")), equal($projeto_origem_c, "")))',
    'triggerFields' => array('projeto_origem_c', 'acc_tipo_cliente_c'),
    'onload' => true,
    'actions' => array(
    array(
    'name' => 'ReadOnly',
    'params' => array(
    'target' => 'projeto_origem_c',
    'value' => 'false',
    ),
    ),
    ),
    'notActions' => array(
    array(
    'name' => 'ReadOnly',
    'params' => array(
    'target' => 'projeto_origem_c',
    'value' => 'true',
    ),
    ),
    ),
    );

    Regards

    André Lopes
    Lampada Global
    Skype: andre.lampada
  • Hi André Lopes

    That's excellent - it was the notActions piece I was missing, so now when I change the value of the field referenced in the trigger, the 'Required' switches on or off

    Thank you

    Neil