Alert when Changing the Category

GUPE
Kilo Explorer

Hi,  

I want a pop-up alert to be displayed when a users changes the Category and/or Subcategory to warn them that this will clear the description field.     I have created a client script with the…

1 ACCEPTED SOLUTION

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hi @Guy Peacock



I hope the below wiki link will answer your question If you are looking fields to be prepopulated based on other field


http://wiki.servicenow.com/index.php?title=Data_Lookup_and_Record_Matching_Support



Please mark your question as answered if it resolves your issue



Thanks


Pradeep Sharma


View solution in original post

8 REPLIES 8

GUPE
Kilo Explorer

Hi,



so what i would like is that if the analyst changes the category it pops up the alert to warn them this will clear the description field. if they click OK it proceeds with the change however if they click Cancel it reverts the change and leaves the details as they are.



Hope this makes sense.


Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hi @Guy Peacock



Just a small change in the script:


function onChange(control, oldValue, newValue, isLoading, isTemplate) {


if (isLoading || newValue == '') {


    return;   }


if(newValue != oldValue)


{


var answer = confirm("The category field on the form have changed.\nDo you really want to save this record?");


if (answer == true) {


g_form.setValue('description','');


return true;


}


else


{


g_form.setValue("category", oldValue);//Just add this line in my previous code


return false;


}


}


    }



Also I have written my script in below demo instance


https://demo002.service-now.com/login.do



Please let me know if you have any issues with the script



Thanks


Pradeep Sharma


Thanks pradeep Sharma and Bhavesh,




The category is now reverting back to the original however and the trick part of this i feel is the details in the description field are still being written over.




I am not sure if there is a way around this as the description auto fills depending on the category you select.




Again you help and suggestions are greatly appreciated.



Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hi @Guy Peacock



I hope the below wiki link will answer your question If you are looking fields to be prepopulated based on other field


http://wiki.servicenow.com/index.php?title=Data_Lookup_and_Record_Matching_Support



Please mark your question as answered if it resolves your issue



Thanks


Pradeep Sharma