- 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-08-2014 08:54 AM
Hi Guy Peacock
Try this "on change client script" on "Category"
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
{
return false;
}
}
}
I hope this helps
Thanks
Pradeep Sharma
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-13-2014 03:34 AM
Hi Pardeep,
I am getting the pop up but there is not change to the category if i click OK or cancel.
Thanks for the help so far,
Guy

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-13-2014 03:40 AM
Hi @Guy peacock
The above script will clear the description field if you click OK.
Can you please let me know what is that exactly you are looking for.
Thanks in advance.
Best regards
Pradeep Sharma

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-13-2014 03:49 AM
Added one line in the above code:
g_form.setValue('category',oldValue);
Final Code :
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);
return false;
}
}
}