Is there a way to know if form has been updated from client side? instead using current.operation() == 'update' ?

guille
Kilo Expert

Hello,

At the client scripts side is there a way to know if form has been updated ? instead using current.operation() == 'update' ? for example like UI policies when state changes set the worknotes as mandatory however this only works for a simple field, would like to know if there is a way for all form fields .

8 REPLIES 8

bernyalvarado
Mega Sage

Hi Guille,



You could have a script like the following in an onSubmit client script



function onSubmit() {


  var field1 = g_form.getControl('caller_id');



  //See if the 'changed' attribute is true


  if(field1.changed){


    return confirm("The Caller field has changed.\nDo you really want to save this record?");


  }


}



Thanks,


Berny


Thanks, but maybe I did not explain well, I'm looking something not for an specific field, we need the entire form, we could   do this by using a BR and use the following clause:


current.operation() == 'update'

That will let Servicenow know that my form have been changed regardless the previously updated field, I'm not sure if it possible.


Ok. You can use...



if (g_form.modified){


      alert ("Something has changed");


}



Thanks,


Berny


bernyalvarado
Mega Sage

Source: Client Scripts - ServiceNow Wiki



Thanks,


Berny