FAQ
How can we help?
Full Site Search

Automatically recalculate formulas after saving the record

If in some cases the formulas on the sheet is not triggered when the record is created, and you would like to trigger formulas recalculation right after saving the record automatically, please follow this guide to add your script:

Step 1: Open the Ragic workflow editor.

Click on the arrow icon of the sheet from the tab and select Javascript Workflow, which will take you to the Workflow Module.

Step 2: Switch edit page to "Post-workflow".

Step 3: Paste, edit the following code and save.

var nodeId = param.getNewNodeId(Key Field);
var path = '/tab_path/sheet_path'; 
var query = db.getAPIQuery(path);
var entry = query.getAPIEntry(nodeId);
entry.recalculateAllFormulas();
entry.setIfDoLnls(true);
entry.setCreateHistory(true);
entry.save();

Please replace the Key Field with the Key field id of your sheet, which you can find it in the workflow editor or you can look up in your data dictionary.

In this example, the line should be replaced to:

var nodeId = param.getNewNodeId(1001404);

And replace '/tab_path/sheet_path' with your own tab and sheet path.

Example If your sheet url is 'www.ragic.com/sample/sales/3', this line would be written as following:

var path = '/sales/3'; 

To recalculate the formulas of certain fields only, you can replace the line

entry.recalculateAllFormulas();

with

entry.recalculateFormula(field id);

For field id please replace it with the field id of the fields that you would like to recalculate. For example, if you would like to recalculate the fields of these field ids: 1000001,1000002,1000003, the result would look something like this:

entry.recalculateFormula(1000001);
entry.recalculateFormula(1000002);
entry.recalculateFormula(1000003);

Top of Page

    Start Ragic for free

    Sign up with Google