Readonly is not working for dropdown field data condition

For readonly field based on condition i followed this guide https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_10.0/Architecture/Sugar_Logic/Dependenc…  and replicate the same code for dropdown field, its now working.

Based on above guide below code is working in our instance, but its not working for dropdown field mentioned below (2nd part of code)

Sample Code shared in Sugar documentation - This is working fine, lock_record_c is Checkbox field.

<?php
$dependencies['Opportunities']['readonly_fields'] = array(
'hooks' => array("edit"),
'trigger' => 'true',
'triggerFields' => array('lock_record_c'),
'onload' => true,
'actions' => array(
array(
'name' => 'ReadOnly',
'params' => array(
'target' => 'total_sqft_rqrd_site_1_c',
'value' => 'equal($lock_record_c,true)',
),
),
),
);
?>

We replicated the same code based on our custom dropdown field but this is not working in our instance we tried multiple options its not working can any one guide us what we're missing here ?

Not working code for dropdown field (quote_stage_approval_status_c)

<?php
$dependencies['Opportunities']['readonly_fields'] = array(
'hooks' => array("edit"),
'trigger' => 'true',
'triggerFields' => array('quote_stage_approval_status_c'),
'onload' => true,
'actions' => array(
array(
'name' => 'ReadOnly',
'params' => array(
'target' => 'total_sqft_rqrd_site_1_c',
'value' => 'equal($quote_stage_approval_status_c,Pending)',
),
),
),
);
?>

  • I think you may be having a conflict with your arrays. In the second file for quote_stage_approval_status_c change the array of $dependencies['Opportunities']['readonly_fields'] to something like $dependencies['Opportunities']['readonly_fields_stage']

  • equal($quote_stage_approval_status_c,Pending)

    In that expression you are missing the double quotes around Pending, so it should be:

    equal($quote_stage_approval_status_c,"Pending")

    Regards

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



    Could you please suggest me, if i want to readonly for relationship field, so what will be the syntax,
    actually i have tired the same but relationship field is unable to change as readonly

    Please suggest
    Thanks in Advance

  •  I had this functionality in a few instances and had to back it out somewhere around 13.0. It started causing issues which I don't quite remember the specifics. I had to go to setting readonly for dropdowns in sidecar.