- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-08-2014 08:17 AM
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…
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-13-2014 04:28 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-13-2014 03:45 AM
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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-13-2014 03:53 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-13-2014 04:05 AM
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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-13-2014 04:28 AM
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