
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-18-2024 04:41 AM
I need close Progress Modal and show Confirmation Modal without button click after getting response from Script Include. Using GlideAjax. Any Suggestions...?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-18-2024 01:28 PM - edited 08-18-2024 01:28 PM
Hello @Community Alums
This is achievable. I tried this in my PDI which is working fine. Try to replicate the same in your instance.
Quick overview:
In my script I'm checking whether user is VIP or not. If the user is VIP, destroying the glidemodal after 2 seconds.
Now you can implement the next steps which is confirmation modal.
Here is my code:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var gm = new GlideModal("glide_progress_no_button", false, 600); // initialize and render the GlideModal
gm.setTitle("User status");
gm.setPreference("title", "Checking user status");
gm.setPreference("warning", "false");
gm.render();
var gAjax = new GlideAjax('global.IncidentUtil'); // glideAjax call to the server-side script
gAjax.addParam('sysparm_name', 'getUserDetail');
gAjax.addParam('sysparm_user', newValue);
gAjax.getXMLAnswer(function(answer) {
answer = JSON.parse(answer);
if (answer.manager == '1') {
onClose(true);
} else {
onClose(false);
}
});
function onClose(value) { // function to close the modal
if (value === true) {
setTimeout(function() {
gm.destroy(); // destroy the modal after 2 seconds
}, 2000);
}
//Now it's time to write your code from here
}
}
Quick demo:
Hope it helps:)
Murthy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-18-2024 11:46 AM
Try using below code in your call back function:
action.setRedirectURL(current)
Please don't forget to mark helpful if the solution solves the problem
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-18-2024 01:28 PM - edited 08-18-2024 01:28 PM
Hello @Community Alums
This is achievable. I tried this in my PDI which is working fine. Try to replicate the same in your instance.
Quick overview:
In my script I'm checking whether user is VIP or not. If the user is VIP, destroying the glidemodal after 2 seconds.
Now you can implement the next steps which is confirmation modal.
Here is my code:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var gm = new GlideModal("glide_progress_no_button", false, 600); // initialize and render the GlideModal
gm.setTitle("User status");
gm.setPreference("title", "Checking user status");
gm.setPreference("warning", "false");
gm.render();
var gAjax = new GlideAjax('global.IncidentUtil'); // glideAjax call to the server-side script
gAjax.addParam('sysparm_name', 'getUserDetail');
gAjax.addParam('sysparm_user', newValue);
gAjax.getXMLAnswer(function(answer) {
answer = JSON.parse(answer);
if (answer.manager == '1') {
onClose(true);
} else {
onClose(false);
}
});
function onClose(value) { // function to close the modal
if (value === true) {
setTimeout(function() {
gm.destroy(); // destroy the modal after 2 seconds
}, 2000);
}
//Now it's time to write your code from here
}
}
Quick demo:
Hope it helps:)
Murthy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-20-2024 04:56 AM
Thanks for this. I have implemented something similar where i utilize the ootb 'loading_dialogue' UI page in a GliceModal, that way when clicking a UI action where the GlideAjax call might take a while, i show the loading UI Page as the first thing, and as soon as the GlideAjax data is ready, i destroy the loading page and then show the new UI Page with the data.
But sometimes both modals would load at the same time, cause the load modal to be behind the other modal, then closing the non loading modal. The loading modal would just sit there and never go away. But this function setup with a timeout stops that from happening 🙂