- 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-26-2023 11:22 PM
Hello @Kruthik M Shiva ,
You need to remove this 3 lines from above code
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 }
Instead add below code please & check
You can create a Confirmation Modal:
var dialog = new GlideModal('glide_modal_confirm', true, 300); dialog.setTitle(new GwtMessage().getMessage('Confirmation')); dialog.setPreference('body', new GwtMessage().format("Your message")); dialog.setPreference('focusTrap', true); dialog.setPreference('onPromptComplete', doComplete); dialog.setPreference('onPromptCancel', doCancel); dialog.render(); function doComplete() { callback(true); } function doCancel() { callback(false); }
No need to create a UI Page.
Please 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-26-2023 11:29 PM
Hi @Danish Bhairag2
Do I need to use the above code in the same client script what all i need to change exactly to the above code can you please elaborate?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-27-2023 12:14 AM
Hi @Kruthik M Shiva ,
Yes u need to update it in the same client script. Just remove those 3 lines which I mentioned in above reply & replace it with
var dialog = new GlideModal('glide_modal_confirm', true, 300);
dialog.setTitle(new GwtMessage().getMessage('Confirmation'));
dialog.setPreference('body', new GwtMessage().format("Your message")); // mention your message here which u wish to display
dialog.setPreference('focusTrap', true);
dialog.setPreference('onPromptComplete', doComplete);
dialog.setPreference('onPromptCancel', doCancel);
dialog.render();
function doComplete() {
callback(true);
}
function doCancel() {
callback(false);
}
Hope this helps you. mark my answer helpful if it helps you resolve your query
Thanks,
Danish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-26-2023 11:37 PM - edited 09-26-2023 11:39 PM
Hello @Kruthik M Shiva ,
The confirm() method functionality is a native modal dialog so it'll depend on the browser. In firefox renders the confirm modal differently, It didn't show the title in Firefox.
If you want to hide the title, then need to use a custom modal using GlideModal api.
Below is the sample code for GlideModel confirm box
var dialog = new GlideModal('glide_modal_confirm', true, 300);
dialog.setTitle(new GwtMessage().getMessage('Confirmation'));
dialog.setPreference('body', new GwtMessage().format("Your message"));
dialog.setPreference('focusTrap', true);
dialog.setPreference('onPromptComplete', doComplete);
dialog.setPreference('onPromptCancel', doCancel);
dialog.render();
function doComplete() {
callback(true);
}
function doCancel() {
callback(false);
}
Refer to product docs for GlideModel here
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-27-2023 05:04 AM
Hi @RAMANA MURTHY G and @Danish Bhairag2 ,
I tried but I am getting javascript error in portal for this can you please tell why is that so tried with whatever you mentioned. please let me know if you know the reason.
Thanks