How to know if a field was modified in a form through a business rule?

Mauricio Guzman
Tera Contributor

Hello, I need a way to know through a business rule if a field was modified, this will be checked every time I save the form or send it

I tried to use the functions of this web page, but it seems that they no longer work at the moment

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

1 ACCEPTED SOLUTION

you can try something like this?

(function executeRule(current, previous /*null when async*/) {


   var gr = new GlideRecord('sys_dictionary');


   gr.addQuery('name=incident^ORname=task^element!=NULL'); // Replace 'incident' by the table that is relevant to you


   gr.query(); 


   while (gr.next()) { 


     if (current[gr.element] != previous[gr.element] ) {


         gs.addInfoMessage ('Field ' + gr['name'] + '.' + gr.element + ' has changed!' ); // Insert your here code to save log where you want


     }   


   }


})(current, previous);

View solution in original post

3 REPLIES 3

Harshad Wagh
Tera Guru

are you looking for any specific field or all fields?

In BR what happens if you use this?

find_real_file.png

I'm looking for all fields

 

you can try something like this?

(function executeRule(current, previous /*null when async*/) {


   var gr = new GlideRecord('sys_dictionary');


   gr.addQuery('name=incident^ORname=task^element!=NULL'); // Replace 'incident' by the table that is relevant to you


   gr.query(); 


   while (gr.next()) { 


     if (current[gr.element] != previous[gr.element] ) {


         gs.addInfoMessage ('Field ' + gr['name'] + '.' + gr.element + ' has changed!' ); // Insert your here code to save log where you want


     }   


   }


})(current, previous);