- 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 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 09:44 PM - edited 09-25-2023 09:44 PM
Hi @Danish Bhairag2
I want the pop up to come as soon as change status that is before saving the form once they change the status to reject that time only that pop up should appear. Can you please tell for that? will it work once user changes the status field before saving form?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-25-2023 09:48 PM
Hello @Kruthik M Shiva ,
The above mentioned code works as you expected, confirm() metho in onChange client script popup when you change the status value, If you click yes, then the answer variable will be true, if you click no, then the answer variable will be false.
You can implement your code in
if(!answer){
}
block
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 - edited 09-25-2023 09:57 PM
Hi @RAMANA MURTHY G
It was working but when confirm thing if we cancel still its selected as reject value but it should set to old value right if i select as cancel. can you please what needs to be done for that?