Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

 

The tricky part about architecting a complete offline solution is to think about various features of the backend and implementing them within the app. For example, our customers have told us early on formula fields would be of utmost importance especially if the application is used offline to calculate amounts on orders and other similar . So here is an example of how you would set up formulae to run offline using Pulsar Settings. 

Object structure here is pretty straightforward. Order is a custom object with a master – child relationship with Account. Order Line Item is another custom object with a master – child relationship with Order. Product is a standalone custom object with a list of products. 

First, you specify the setting that dictates the order of the fields calculated; in this example, we grab the Product Unit Price, Discount and then calculate the amount based on the two fields. 

(Note: You can make them record type specific as well. If you want record type specific formulae, just add record type after the object name in the key)

Name: Order Line Item – Formula Order
Key: pulsar.Order_Line_Item__c.formulaFieldOrder
Value: Unit_Price__c,Total_Discount__c,Amount__c

Now to define the formulae of the fields:

Name: Order Line Item – Formula Fields – Unit Price
Key: pulsar.Order_Line_Item__c.Unit_Price__c.formula
Value: 

DEFAULT{
Action=SetVar;
VarName=UnitPrice;
VarValue=Product__r.Unit_Price__c;
|
Action=SetFieldInMemory;
FieldType=General;
FieldName=Unit_Price__c;
FieldValue=%%UnitPrice%%;
}

Name: Order Line Item – Formula Field – Total Discount
Key: pulsar.Order_Line_Item__c.Total_Discount__c.formula
Value:
DEFAULT{
Action=SetVar;
VarName=PromotionDiscount;
VarValue=Product__r.Discount__c;
|
Action=SetVar;
VarName=Discount;
VarValue=Discount__c;
|
Action=SqlQuery;
QueryString=SELECT (CAST(‘%%PromotionDiscount%%’ AS REAL) + CAST(‘%%Discount%%’ AS REAL)) AS TotalDiscount;
QueryReturnFields=TotalDiscount;
|
Action=SetFieldInMemory;
FieldType=General;
FieldName=Total_Discount__c;
FieldValue=%%TotalDiscount%%;
}

Name: Order Line Item – Formula Field – Amount
Key: pulsar.Order_Line_Item__c.Amount__c.formula
Value:
DEFAULT{
Action=SetVar;
VarName=Amount;
VarValue=(Unit_Price__c * Quantity__c) – (Unit_Price__c * Quantity__c * Total_Discount__c);
|
Action=SetFieldInMemory;
FieldType=General;
FieldName=Amount__c;
FieldValue=%%Amount%%;
}

And Now the formula settings on the Order Object:

Name: Order – Formula Field
Key: pulsar.Order__c.formulaFieldOrder
Value:
Total_Amount__c

Name: Order – Formula Fields – Total Amount
Key: pulsar.Order__c.Total_Amount__c.formula
Value:
DEFAULT{
Action=SetVar;
VarName=TotalAmount;
VarValue=Sub_Total__c + (Sub_Total__c * Tax__c);
|
Action=SetFieldInMemory;
FieldType=General;
FieldName=Total_Amount__c;
FieldValue=%%TotalAmount%%;
}

  • No labels