Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

how to check if field values changed before save

Wade Clairmont
Tera Guru

Hey there,

I am trying to update my table specific Update & Save UI actions to check if any values have changed before UI action executes.   I am sure there is an action out there, but is there one that will work with UI Actions.

If I copy a record, is there   way to check if any values have changed since the original copy?   Here is what I have:

var ts = new GlideRecord('u_time_sheet');

ts.addQuery('u_week_starts_on', current.week_starts_on);

ts.query();

if (ts.u_week_starts_on != '') {

  gs.clearMessages();

  gs.addErrorMessage('A timesheet already exists for that time period. Please verify and try again. ');}

  else {

  action.setRedirectURL(current);

  current.update(); }

  if (! current.isActionAborted())

  action.setRedirectURL(current);

I know that this will execute and give the error not matter what, cause the record will always be there, hence.... I have to test to see if any value changed.

Any help would most appreciated.

Thanks in advance!

1 REPLY 1

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hi Wade,



The below article should answer your question.


http://www.servicenowguru.com/scripting/business-rules-scripting/checking-modified-fields-script/



I hope this helps