FAQ
How can we help?
Full Site Search

Generating last modification date & time of a specific field in the entry

In Ragic, you can set up default value to auto populate a date field with the last modification date & time of the entry. However, if you need to auto populate the field with the last modification date & time of a specific field in the entry, you’ll need to add a script to achieve it.

Please follow this guide to add your script:

Step 1: Open the Ragic workflow editor

Right-click on any of the application tabs or sheets and select Javascript Workflow or 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

Independent fields :

function setLastModifiedOnField(pathSheet, observeField, recordField) {

if (param.getOldValue(observeField) !== param.getNewValue(observeField) ||

param.isCreateNew()) {

var today = new Date(new Date().getTime() + account.getTimeZoneOffset());

function pad2(n) { return n < 10 ? '0' + n : n }

var fmtValue = today.getFullYear() + "/" +

pad2(today.getMonth() + 1) + "/" +

pad2(today.getDate()) + " " +

pad2(today.getHours()) + ":" +

pad2(today.getMinutes()) + ":" +

pad2(today.getSeconds());

var query = db.getAPIQuery(pathSheet);

query.addFetchDomains(recordField);

var entry = query.getAPIEntry(response.getRootNodeId());

entry.setFieldValue(recordField, fmtValue);

entry.save();

}

}

Subtable fields :

function setLastModifiedOnSubtableField(pathSheet,observeSubtableKeyField, observeSubtableField, recordField) {

var list = param.getSubtableEntry(observeSubtableKeyField);

var entry = param.getUpdatedEntry();

var today = new Date(new Date().getTime() + account.getTimeZoneOffset());

function pad2(n) { return n < 10 ? '0' + n : n }

var fmtValue = today.getFullYear() + "/" +

pad2(today.getMonth() + 1) + "/" +

pad2(today.getDate()) + " " +

pad2(today.getHours()) + ":" +

pad2(today.getMinutes()) + ":" +

pad2(today.getSeconds());

for (var i = 0; i < list.length; i++) {

if(list[i].getOldValue(observeSubtableField) != list[i].getNewValue(observeSubtableField) && (list[i].getOldValue(observeSubtableField) !== null || list[i].getNewValue(observeSubtableField) !== "" )){

var subRootNodeId = list[i].getSubRootNodeId();

entry.setSubtableFieldValue(recordField, subRootNodeId, fmtValue);

entry.save();

}

}

}

Step 4: Switch edit page to "Post-workflow" of the sheet you'd like to add this script

If your sheet URL is https://www.ragic.com/accountname/tabname/1

And

The field whose last modification date & time you’d like to generate is "Active Status" (field ID 1003114), and the field where you’d’ like to record last modification date & time of field "Active Status" is "Last Edit (status)" (field ID 1003115).

Add this to the Post-workflow:

Independent fields :

setLastModifiedOnField("/tabname/1", 1003114, 1003115);

To find out more about how to look up a field ID, click here.

*Please note that when creating a new entry, the last modification date & time will be auto-generated after saving even if the the specific field is not filled. If you wish to keep the last modification date & time empty in this case, you can replace with below script in your Post-workflow:

if(param.getOldValue(1003114) !== null || param.getNewValue(1003114) !== "" ){

setLastModifiedOnField("/tabname/1", 1003114, 1003115);

}

Subtable fields :

setLastModifiedOnSubtableField("/tabname/1", subtablekeyField, 1003114, 1003115);

You can find Subtable key Field in Download Data Dictionary

Don't forget to save your changes.

(The populated date & time value is based on the timezone set in your Company Setting.)

Top of Page

    Start Ragic for Free

    Sign up with Google