This is Post 3 in a series of posts about PSL(Pulsar Settings Language). Let us take a look today at setting up triggers. Just like the Salesforce Backend, Pulsar supports the following trigger points, so upon various actions you could take on object (Create, Edit and Delete), you can set up code to run (for example: update another record in the DB).
1. onCreate
2. beforeEdit
3. beforeSave
4. onSave
5. beforeDelete
6. onDelete
For example: The following setting for onSave action for Order Line Item object runs the code to update the total amount on the Order object. The logic here is pretty straightforward. Upon successful save of the Order line item, it updates the Sub_total__c filed in the parent Order object and the next time Pulsar syncs the data, the updated Order object is pushed to the server. Some of our customers use this feature to run the business logic while offline enabling the field rep to be productive. Pretty convenient!
Name: On Save – Order Line Item
Key: pulsar.onSave.Order_Line_Item__c
Value:
DEFAULT{
Action=SetVar;
VarName=Order_Id;
VarValue=Order__c;
|
Action=SqlQuery;
QueryString=Select SUM ( CAST( Amount__c AS REAL ) ) AS SUM_ORDER_AMOUNT FROM Order_Line_Item__c WHERE Order__c = ‘%%Order_Id%%’;
QueryReturnFields=SUM_ORDER_AMOUNT;
|
Action=SqlQuery;
QueryString=Update Order__c SET Sub_Total__c = ‘%%SUM_ORDER_AMOUNT%%’ WHERE Id = ‘%%Order_Id%%’;
}