- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-25-2023 09:16 PM
Hi All,
I have a requirement to pop up confirm if you have to reject the form and two choices should be there in pop up as yes or no if they select as change to reject status else previous status only be set. Please do share what needs to be done for this and if any scripting required please help on that as well.
Thanks in advance.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-25-2023 09:37 PM
Hi @Kruthik M Shiva ,
Kindly refer below code to achieve your requirement.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
if(newValue == 'rejected'){ // please use proper backend name of the reject status
var answer = confirm('Do you wish to proceed with Rejecting the change');
if(!answer){
return false;// this will not allow the user to save the form with reject status
}
}
}
Please mark my answer helpful & accepted if it helps you resolve your issue.
Thanks,
Danish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-25-2023 10:04 PM
HI @Kruthik M Shiva ,
For that you need to write else block as
if(!answer){
// your block
}
else{
g_form.setValue('status',oldValue);
}
Please mark my answer correct and helpful, if it helps you
Thank you
Thank you
G Ramana Murthy
ServiceNow Developer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-25-2023 09:56 PM
Hi @Kruthik M Shiva ,
U need to add that code in On change script where variable you will select as status.
So whenever some1 changes the status to reject the onChange script will execute.
Mark my answer helpful & accepted if it helps you resolve your query.
Thanks,
Danish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-25-2023 09:59 PM
Hi @Danish Bhairag2 ,
But when the confirm pop up comes if i select as cancel as well i can see status as reject in form but if i select as cancel it should ideally set whatever the previous status right if we click ok then only it should be set as new value
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-25-2023 10:03 PM - edited 09-25-2023 10:07 PM
Hi @Kruthik M Shiva ,
Please add 1 line in below code
if(!answer){
g_form.setValue('status',oldValue);
}
Please mark my answer helpful & accepted if it helps you resolve your issue.
Thanks,
Danish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-26-2023 11:02 PM
Hi @RAMANA MURTHY G , @Danish Bhairag2 ,
Is there anyway i can remove the title please do let me know and how to remove it.
PFB screenshot for reference.
Thanks