Alert a Message and Notification on change of any field on the form

kavyahv
Kilo Contributor

Dear All,

I need to alert a message and a notification needs to be triggered on change of   any of the field on the form.

Please help.

Thanks & Regards,

Kavya

1 ACCEPTED SOLUTION

Abhinandan Pati
Giga Guru

Hi Kavya,



You can use 'g_form.modified method to check for changes on the form. And on the server side you can make use of   'GlideScriptRecordUtil' methods. Below mentioned wonderful SNOWGuru article should help you



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



Thanks,


Abhinandan


View solution in original post

18 REPLIES 18

mayurkamble
Kilo Guru

Hi Kavya,



I think for your requirement UI Policy would be a better option.


In when to run add all those fields, on change of which you want alert and Mandetory thing, let it be like User name changes or Username is not Same OR email changes.


"OR" all your fields.


Now in action make the field mandetory.


Or write a script for mandatory and alert.



Now foe email notification you can go foe about the same approch. In notification select your table.


And put the conditions similer to UI policy and trigger the mail.


This will work. Upto my understanding of your requirement.




Regards,


Mayur


kavyahv
Kilo Contributor

Hi All,



I have written below business rule , but unfortunately it does not seem to worl.



function onBefore(current, previous) {



  gs.addInfoMessage("data modified");


  g_scratchpad.comments == true;


  current.setAbortAction(true);


   


}



and Client script



function onLoad() {


  alert(g_scratchpad.comments);


  if(g_scratchpad.comments == 'true')  


            g_form.setMandatory('comments', true);  


   


}


Kavya,



Please try what I mentioned in my earlier comment and let me know.



Hi kavya,



You can use business rule on insert/update for this...



Choose advanced and write script like



if(current.assignment_group.changes())


{



gs.eventQueue("field changed",current,gs.getUserId(),gs.getUsername());


}



Then create an event by going to event registry .Do same for other fields in same code.I hope this helps



Mark Correct if it solved your issue or hit Like and Helpful if you find my response worthy.


Thanks,
Deepa


Kavya,



    g_scratchpad object is only available for Display business rules. Change your Business rule from before to display business rule


Let us assume you have a field "description" on the form. You want to make comments mandatory when description field is changed. This is how your script looks


Display Business rule:


g_scratchpad.description= current.description;



client script: onSubmit:


script:


if(g_form.getValue('description')!=g_scratchpad.description){


alert(' Comments are required');


g_form.setMandatory('comments', true);


return false;


}



Thanks,


Abhinay



PS: Hit like, Helpful or Correct depending on the impact of the response


Abhinandan Pati
Giga Guru

Hi Kavya,



You can use 'g_form.modified method to check for changes on the form. And on the server side you can make use of   'GlideScriptRecordUtil' methods. Below mentioned wonderful SNOWGuru article should help you



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



Thanks,


Abhinandan