Using Business Rules for State-Based Process Definitions in SugarCRM

Hi everyone,

I’ve recently come across a scenario that involved a Process Definition with a somewhat complicated gateway. The objective was to create a flow that diverged into six different paths depending on which of the 50 states was selected in the record's "State" field. Initially, the solution was built using a gateway, but with 50 states to account for, this became cumbersome to manage and maintain.

This got me thinking—there’s a much cleaner, more efficient way to handle this kind of logic by using Business Rules. Instead of building a complex gateway with a decision for each state, a Business Rule allows us to centralize this logic in a more manageable format.

 

Why Business Rules Make Sense

 Having many conditions in a gateway:

  1. is difficult to read and understand
  2. is difficult to make minor adjustments to over time
  3. cannot be easily reused in other process definitions requiring similar logic
  4. must be rewritten if the outbound sequence flow lines need to be replaced

 

Business Rules are the perfect alternative.

  1. Business Rule configuration is laid out in an easy-to-read table
  2. Adjusting any one row doesn’t interfere with the rest
  3. The same Business Rule can be used in any number of process definitions
  4. Editing process definition elements do not impact the content of the Business Rule

  

Using Business Rules With Gateways

Business Rules output a “Return Value” that can be used in gateways, so you can still apply your gateway model, but now with much simpler criteria, making readability and maintenance of the process definition much simpler.

Here is a screenshot showing the first few rows of a Business Rule for Leads that outputs a region value based on the state value in the target record:



That first conclusion, labeled “Return Value” is not a value that is saved into any fields on the target record. Rather, it is a spontaneous output that can be read by a gateway.

Here is a process definition with a Business Rule followed by a gateway, showing the simple gateway conditions:



Using Business Rules to Update Fields

Business Rules can also provide a simpler and cleaner solution compared to gateways when you need to update fields based on the conditions. Using a gateway, you will need to add Change Field actions to the definition and then map the gateway’s conditions to those paths. In a Business Rule, though, you can add any number of Conclusion columns and change the fields right there in the Business Rule.

Here is a screenshot of the Business Rule shown above, but now configured to change the target record’s Assigned to field based on the results of the Business Rule:



I hope this helps simplify your workflows, especially if you find yourself dealing with complex branching logic in your Process Definitions! If you have any questions or need further guidance, feel free to ask!