- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-08-2020 11:51 PM
Hi,
I want to create UI page. In that UI page client script want to display confirm dialog box. When users click on "Ok" trigger
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-09-2020 10:38 PM
Hi,
when you click cancel you are redirecting to new page and form will stay there only
add this
function onCancel() {
var uri = 'home.do';
g_navigation.openPopup(uri);
return false;
}
after processing script is triggered you can redirect to whichever url you want as below
runprocessCode();
function runprocessCode(){
gs.info('Processing script triggered');
// ensure you give valid object for your event queue current won't work here
gs.eventQueue('sendNotification',current, gs.getUserID());
var url = 'your URL here';
response.sendRedirect(url);
}
Let me know if I have answered your question.
If so, please mark appropriate response as correct & helpful so that this thread can be closed and others can be benefited by this.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-09-2020 09:22 PM
Sample script below
HTML:
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<g:ui_form>
<table border="0" width="100%">
<tr>
<td>
<input type="hidden" name="reason" id="reason"></input>
</td>
</tr>
<tr>
<td>
<g:dialog_buttons_ok_cancel cancel="return onCancel();" ok="return onSubmit();"/>
</td>
</tr>
</table>
</g:ui_form>
</j:jelly>
Client Script:
function onCancel() {
var uri = 'home.do';
g_navigation.openPopup(uri);
}
function onSubmit() {
return true;
}
Processing Script: once you click OK in system logs you should see the processing script log
runprocessCode();
function runprocessCode(){
gs.info('Processing script triggered');
// ensure you give valid object for your event queue current won't work here
gs.eventQueue('sendNotification',current, gs.getUserID());
}
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-09-2020 10:03 PM
Ankur,
Thanks for the reply. I tried this script when I click on Cancel button also Processing script is triggering. Also can we place any redirection url after the event triggered?
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-09-2020 10:38 PM
Hi,
when you click cancel you are redirecting to new page and form will stay there only
add this
function onCancel() {
var uri = 'home.do';
g_navigation.openPopup(uri);
return false;
}
after processing script is triggered you can redirect to whichever url you want as below
runprocessCode();
function runprocessCode(){
gs.info('Processing script triggered');
// ensure you give valid object for your event queue current won't work here
gs.eventQueue('sendNotification',current, gs.getUserID());
var url = 'your URL here';
response.sendRedirect(url);
}
Let me know if I have answered your question.
If so, please mark appropriate response as correct & helpful so that this thread can be closed and others can be benefited by this.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-09-2020 10:45 PM
Thank you Ankur!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-09-2020 11:09 PM
You are welcome.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader