Editor’s Note: This is the first post in a series of examples on how to use some of the new features added to SugarCRM in 6.1 and 6.2 powered by Sugar Logic.
Creating a commission field that is automatically recalculated based on the amount and type of opportunity is easy using SugarLogic and Calculated Fields.
We’ll start by creating a new field of type currency called “commission_c”. Once we check the “Calculated” checkbox, the “Edit Formula” button appears. Clicking the button will bring up the Formula Builder where we can enter the logic to drive our new field.
On the left we have a list of all the functions, and on the right a list of all the fields we can use in our formula. In this example, we will set the value of the commission to be 7% of the amount for “New Business”, and 5% for any other type of opportunity. The formula will be:
ifElse(equal($opportunity_type, "New Business"), multiply($amount, 0.7), multiply($amount, 0.5) )
Now we just need to hit save on the Formula Builder, save again on the field editor, and finally add the field to the layouts. If we add the field to the Edit View, the field will recalculate in real time, but it will be read only. However, we don’t have to add the field to the Edit View in order to have the field calculated.