Ragic Logo
<< Slow database connection troubleshootingTable of ContentsGuide to server-side Javascript Workflow >>

Automatic daily recalculation

If you change a formula or a variable that is used in a formula very often, you have the option to add a script that will recalculate your formula every day. Please follow this guide to add your script:

Step 1: Open the Ragic workflow editor.

Right-click on any of the application tabs and select Global Javascript Workflow, which will take you to the Workflow Module.

Step 2: Switch edit page to "Global Workflow".

Step 3: Paste the following code and save.

function dailyFormulaRecalculate(pathSheet){

var pageSize = 1000; //read 1000 entries at a time

var qMain = db.getAPIQuery(pathSheet);

qMain.setUpdateMode();

var mainAr = null, mainOffset = 0;

while(mainAr==null || mainAr.hasMore()){

qMain.resetData();

qMain.setLimitSize(pageSize);

qMain.setLimitFrom(mainOffset);

mainAr = qMain.getAPIResults();

var iterator = mainAr.iterator();

while(iterator.hasNext()){

var entry = iterator.next();

entry.recalculateAllFormulas();

entry.save();

}

mainOffset += mainAr.getData().size();

}

}

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. So the result would look something like this:

entry.recalculateFormula(1000001);

entry.recalculateFormula(1000002);

entry.recalculateFormula(1000003);

To recalculate the 3 fields: 1000001,1000002,1000003

Step 4: Switch edit page to "Daily Workflow".

If the URL link of the sheet you want to do this job is https://www.ragic.com/accountname/tabname/1

Add this to the daily workflow:

dailyFormulaRecalculate("/tabname/1");

Don't forget to save your changes.

Top of Page
<< Slow database connection troubleshootingTable of ContentsGuide to server-side Javascript Workflow >>
Learn more about Ragic:
Why we created Ragic
Webinars
User Guide
Keep in touch:
Blog
Email
Facebook
Twitter
Ragic, Inc.
1-888-666-8037
Terms
Privacy