- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-14-2016 12:19 AM
Hi All,
I have the requirement that : On the incident form their is incident status code as cancelled.
When the user clicks on that i want a pop up saying : " Do you want to cancel this incident " and two buttons should be their i.e., Yes or no.
If user clicks yes the ticket should get cancelled and if he clicks no then it should remain in the same page.
Kindly provide your input.
Regards,
Shristy
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-14-2016 03:09 AM
Hi shrishty,
Try this code
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var value = g_form.getValue('incident_state');// field name
if(value==12) // field value
{
if(confirm("Do you want to cancel"))
{
g_form.save();
}
else
{
g_form.setValue('incident_state',oldValue);
}
}
}
Regards,
Raveena Bhatia
PS:Mark this answer as correct or useful or hit like
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-14-2016 02:06 AM
Hi Gurpreet/Mihir/Srinivas/Raveena,
As i have have created the onchange script with the help of you and mihir,kindly help me with glide dialogue window please.
I am new to servicenow and dont have much idea about it.
I went to link but couldnot find out what to be done.
Kindly help.
Regards,
Shristy

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-14-2016 02:27 AM
Hi,
try this, change the field name as per your requirement.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
//Type appropriate comment here, and begin script below
var value = g_form.getValue('incident_state');// field name
alert("value" +value);
if(value==6) // field value
{
alert("inside if");
if(!confirm("do you want to cancel"))
g_form.setValue('incident_state',oldValue);// it will return to previous value if cancelled.
}
}
Harish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-14-2016 02:42 AM
Hi Shristy,
This code can help you,change according to your requirement.
function submitConfirm() {
if (confirm('Are you sure you want to submit a priority one incident?')) {
g_form.setValue('priority', '1');
if (g_form.isNewRecord()) {
g_form.save();
} else {
g_form.submit();
}
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-14-2016 03:09 AM
Hi shrishty,
Try this code
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var value = g_form.getValue('incident_state');// field name
if(value==12) // field value
{
if(confirm("Do you want to cancel"))
{
g_form.save();
}
else
{
g_form.setValue('incident_state',oldValue);
}
}
}
Regards,
Raveena Bhatia
PS:Mark this answer as correct or useful or hit like
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-14-2016 03:12 AM
Hi Raveena/Akshay/Gurpreet/Mihir/Srinivas,
Thank you for your valuable time spent on this query.
My issue is resolved with the help of you all.
Regards,
Shristy Agrawal