Learning Sugar Logic: Using custom dependencies.

sugarcrmdevelopers —  June 13, 2011 — 17 Comments

One of the more powerful features in Sugar Logic is the ability to craft custom Dependencies that can leverage Actions and more complicated Triggers not made available in Studio.

The complete list of Actions available in 6.2 out of the box is:

Class Action Name Parameters Comments
AssignToUserAction AssignTo value: String username
PanelVisibilityAction SetPanelVisibility target: id of panel to hide
value: Formula used to determine if the panel should be visible
Doesn’t work on tabbed layouts.
ReadOnlyAction ReadOnly target: Name of field to make read only
value: Formula used to determine if the panel should be visible
Used by calculated fields to prevent editing.
SetOptionsAction SetOptions target: Name of field to make modify
keys: List of option keys for the dropdown.
label: List of option labels for the dropdown.
Used by Dependent Dropdowns
SetRequiredAction SetRequired target: Name of field to make required
label: id of label element for this field
value: Formula used to determine if the field should be required.
SetValueAction SetValue target: Name of field to modify
value: Formula to get the value for target field
Used by Calculated fields
VisibilityAction SetVisibility target: Name of field to hide
value: Formula used to determine if the field should be visible.
Used by Dynamic fields

In this example, we are going to create an extension that will add a dependency that uses the SetRequiredAction to make the resolution field required when the status of a case is Closed.


All we need to do is to create an extension file:


After creating the extension file, you’ll just need to hit “Quick Repair and Rebuild” and the new dependency should be active.


17 responses to Learning Sugar Logic: Using custom dependencies.


    I followed your code example above.  The code works fine in the EditView but when you create a case from the TaskBar at the top of the screen it doesn’t have any effect.  Any ideas?


    In case you need what formulas can be used as value:
    and(option1, option2, optionN)
    not(option1)or(option1, option2, optionN)

    Note that option can be any other formular like so:


    How do you utilize a MultiSelect to trigger a dependent field?


    I’m using SugarCRM Version 6.3.0RC2 (Build 6943) and this thing don’t work at all. This is still extended on this version right?


    I’m not sure the notation on “TriggerFields” is clear. It sas “when the trigger is true” which, to me, suggests that some expression would go there. But looking at the Trigger.php script, it seems it is considered true when the field has been set. I’m also unclear on the “value” param for a dependently required field, is this meant to act as a default value? Or a calculated value? Can the field be overwritten (by default?). If it is dependent but unknown, can the formula be “equal($field, “”) ?


    How I can make dependent dropdowns?


    Here’s an example for making a panel visible. Had some trouble initially getting it working. My problem was I was using ‘PanelVisibilityAction’ as my ‘name’. Make sure you always use the 2nd column (that’s the action name, the first is the ClassName).

    One thing to note: the panel id is assigned sequentially… First panel is detailpanel_1, 2nd is detailpanel_2, the 3rd is detailpanel_3… As a result, if you ever reorder the panels, your visibility logic will hide the wrong one.

    I’ve been wanting to do this for a long time! This blog continues to be the source of documentation I turn to. Out of curiosity I checked the developer guide… this was added to it 10 days ago… Perfect example of why I never look there and always search this blog.

    Venkata Krishna January 2, 2014 at 3:48 am

    I wanted a similar thing in Sugar 7. And this doesn seem to work in Sugar 7(worth a try). Also tried by doing some, what i thought would be necessary, changes like
    ‘hooks’ => array(“edit”), to ‘hooks’ => array(“record”),
    Still, no luck.
    Any help ?


    What’s up to every one, the contents existing at this website are
    truly remarkable for people knowledge, well, keep up the good work fellows.


    is there a way to do this in SugarCRM 7.2 ?


    i want to use equal($val,”string%”).. how can i do that can you let me know..

Trackbacks and Pingbacks:

  1. how to validate the depending fields in the sugarcrm - March 13, 2012

    […] […]

  2. depending required fields - June 12, 2012

    […] […]

  3. Hide Panels in EditView (6.5) - Page 2 - October 18, 2012

    […] […]

  4. SugarCRM Developer Blog » Blog Archive » Using Sugar Logic to conditonal make fields read only - November 8, 2012

    […] 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 […]

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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