SetValue dependency file not working on basic text field

Hi,

Trying to get the SetValue dependency file working on a basic text field using a dependency file.

I have used successfully before on a decimal field but struggling here.

Below is an example of the dependency file I have placed into ...\custom\Extension\modules\Opportunities\Ext\Dependencies\<dependencyfile.php>

I expect when I create an Opportunity record, the value 'ABC' will appear in the text field, however it is just showing empty.

I tested the logic by putting the value in as a Calculated Field in Studio and that works. However, I need to use the Dependency file approach for my real life example as it is more complex than this basic test. In my real life example I also got it to work in Studio, but not working in the Dependency file.

Help will be much appreciated.

Thanks

Neil

<?php
/*
Set Default Values - Opportunities
*/


// test SetValue
$dependencies['Opportunities']['setvalue_dep_test'] = array(
'hooks' => array("edit", "view"),
'trigger' => 'true',
'onload' => true,
//Actions is a list of actions to fire when the trigger is true
'actions' => array(
array(
'name' => 'SetValue',
//The parameters passed in will depend on the action type set in 'name'
'params' => array(
'target' => 'symtest_text_c',
'value' => 'ABC',
),
),
),
);

Parents
  • Hi Neil, 

    Could you try following:

    <?php
    // test SetValue
    $dependencies['Opportunities']['setvalue_dep_test'] = array(
        'hooks' => array("all"),
        'trigger' => 'true',
        'onload' => true,
        //Actions is a list of actions to fire when the trigger is true
        'actions' => array(
            array(
                'name' => 'SetValue',
                //The parameters passed in will depend on the action type set in 'name'
                'params' => array(
                    'target' => 'symtest_text_c',
                    'value' => '"ABC"',
                ),
            ),
        ),
    );
    

    Best Regards

    Tevfik Tümer
    Sr. Developer Support Engineer

  • Hi

    Thanks for your prompt response.

    I tried your recommendation of enclosing the text in " " and that worked - see below.

    Many thanks

    Neil

    My real case scenario was using a getDropDownValue based on another field, so I assumed I couldn't wrap that in " "

    So as part of my earlier testing I changed the trigger from true to the dependent field not being empty.

    This seems to have got it working - not sure I fully understand why changing the trigger from a default of true to conditional true has made the difference.

    $dependencies['RevenueLineItems']['setvalue_dep_mtrname'] = array(
    'hooks' => array("edit", "view"),
    'trigger' => 'not(equal($sym_adv_std_matter_c, ""))',
    'onload' => true,
    //Actions is a list of actions to fire when the trigger is true
    'actions' => array(
    array(
    'name' => 'SetValue',
    //The parameters passed in will depend on the action type set in 'name'
    'params' => array(
    'target' => 'sym_adv_matter_name_c',
    'value' => 'getDropdownValue("sym_adv_std_matter_list", $sym_adv_std_matter_c)',
    ),
    ),
    ),
    );

  • Hi ,

    I'm glad it worked. 

    I'm guessing in your use case your list does not have empty value in it. That could be the problem. 
    You can also wrap your value with a ifElse to check if the target field is empty or not. 

    In example:

                    'value' => 'ifElse(not(equal($sym_adv_std_matter_c, "")), getDropdownValue("sym_adv_std_matter_list", $sym_adv_std_matter_c), "")',
    

    Best Regards

    Tevfik Tümer
    Sr. Developer Support Engineer

Reply
  • Hi ,

    I'm glad it worked. 

    I'm guessing in your use case your list does not have empty value in it. That could be the problem. 
    You can also wrap your value with a ifElse to check if the target field is empty or not. 

    In example:

                    'value' => 'ifElse(not(equal($sym_adv_std_matter_c, "")), getDropdownValue("sym_adv_std_matter_list", $sym_adv_std_matter_c), "")',
    

    Best Regards

    Tevfik Tümer
    Sr. Developer Support Engineer

Children
No Data