AnsweredAssumed Answered

Some fields cannot be made readonly

Question asked by Andrew Gin on Feb 21, 2017
Latest reply on Mar 26, 2018 by r. adrian aguilera perez

Hi

This is my code:

<?php
$dependencies['Opportunities']['lock_engagement_dep'] = array(
    'hooks' => array("edit"),
    'trigger' => 'equal($sales_stage, "Closed Won")',
    'triggerFields' => array('sales_stage'),
    'onload' => true,
    //'actions' => $actions,
    'actions' => array(
            array(
                    'name' => 'ReadOnly',
                    'params' => array(
                            'target' => 'con_cost_c',
                            'value' => 'true',
                    ),
            ),
            array(
                    'name' => 'ReadOnly',
                    'params' => array(
                            'target' => 'description',
                            'value' => 'true',
                    ),
            ),
    ),
);

 

In this instance, description is readonly, but I can still edit the cost field (con_cost_c).

My question is: Are there certain fields that cannot be made readonly with custom dependencies and sugarlogic?

 

EDIT:
The above code is modeled after the documentation here:

http://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_7.9/Architecture/Sugar_Logic/Dependency_… 
However this code does not work if some of the readonly fields have conditional visibility (set in Admin/Studio/(module)/(field)). Ie, its visibility is dependent on the value of another field.

Is there a solution to this?

 

Detail:

In SUGAR.forms.Dependency.prototype.fire, it will first go through this code to make the fields readonly (which is what we want) using SUGAR.forms.ReadOnlyAction.

Then it will run through again going through the visibility dependencies, in this case, making the field visible if the formula is true. It will use SUGAR.forms.SetVisibilityAction and reenable these fields.

Outcomes