A common customization for SuiteCRM is controlling the user behavior while editing records. A couple of examples are forcing a field to be filled based another field value, updating a field based on the input of another field, or locking editing of the record based on a field value.

Some of these customizations can be done in either the UI or some simple vardef field definitions but we are limited in what we can do. For example it is easy to make a field required in Studio but you cannot make it required based on the value of another field such as forcing the description of a Lead to be filled in if the status moved from New.

SugarCRM 7 makes this fairly easy either by using the calculated field functionality or within the Backbone framework. While there isn’t any built in framework in SuiteCRM we can achieve similar results by using javascript.The advantage of using javascript versus a logic hook is we handle the logic while the user is interacting with the edit form and can also display information to the user on why the action isn’t allowed.

Here is an example of how to lock editing of a record based on a field value. While this is a bit of a trivial example the possibilities are wide open.

First we will add a new javascript file

Then in the actual javascript file we have disabled all fields based on the Account name. In a real world example the logic would likely impact select fields based on another field value such as requiring the description to be at least 8 characters. We could also handle field changes to check the new value compared to other field values to handle business rules.

If you have in-line editing enabled we would need to apply similar logic to the detail view to conditionally handle the in-line edit icon. The javascript file would be enabled similar to the edit view file above.

Categories: Uncategorized

Related Posts

Sugar Outfitters

Background Updater for SugarCRM Version 2

Background Updater for SugarCRM version 2 now available.

Uncategorized

Dashboard Manager Now for SugarCRM 7

We have just updated our Dashboard Copy Manager to be compatible with SugarCRM 7 On-Demand. Dashboard Copy Manager allows admins to quickly copy Home, List View, and Record View dashboards to Users, Teams, and Roles. Read more…

SugarCRM

Easy PayPal Addon

This is just a quick and easy tip for adding payment options to your SugarCRM or SuiteCRM Invoices to make it easier to get paid and get paid faster. PayPal has a nice feature called Read more…