Using Sugar Logic to conditonal make fields read only

sugarcrmdevelopers —  November 8, 2012 — 4 Comments

I saw a great question recently on the forums

i have want Relate field make read only for the particular condition.When user create new record then Relate field is editable but user edit the record then relate field make read only .

This is a prime case for using Sugar Logic, as at the code level there are many other Actions available aside from the pedestrian ones that can be edited in Studio itself. For this use case, the ReadOnly comes into play, and thanks to community member and CTO at Sugar partner NEPO Systems Jeff Bickart here is a great code example on how to do this…

Thanks Jeff for the great example! And as a reminder, this only works for the commercial editions of Sugar ( i.e. not CE )

4 responses to Using Sugar Logic to conditonal make fields read only


    Didn’t realize this was built in like this. Nice tip.


    I added a field in the Users module to classify every user into the subsidiary he/she works in.
    There are some fields that should only be used by some subsidiaries and doing this with the ACLRoles is far too much work.
    So I tried this ‘trigger’ => equal($current_user->subsidiary, ‘tta’), but it didn’t work… it possible to define a trigger for the $current_user or for any field outside of the module the depency works in?


    I also want to integrate the same functionality like make a field editable while adding record. But the same field will non editable while editing the record. I saw the above example but i have few doubts. I thinks i have to replace the “name” with my field name in the following ‘target’ => ‘name’ . I dont know what is $a_boolean in ‘trigger’ => ‘equal($a_boolean,true)’ . what i have to replace with this. Can you help me to sort this issue ?


    Are there certain fields that cannot be made readonly? I cannot make for example con_cost_c readonly

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s