Show values in a list collector variable in a confirm window whenever you submitt a catalog item
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2023 12:57 AM
Hello Everyone,
Please suggest me how to show value in a list collector variable into a confirm window whenever you submit a catalog item , I am using " confirm('Do you want to continue with for ' + array + '?'); " in the onSubmit client script, i am getting sysIDs, need to show display value.
Thank you.....
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2023 03:54 AM
You'll need your onSubmit script to call a GlideAjax with the variable value. The Script Include will query the referenced table and return a list of the display values. So something like this if we're talking about a list collector on the sys_user table. If you're using Service Portal, you'll need to do something else as the submit will complete before the response is received from the server, so the confirmation will appear after the request has been created.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var ga = new GlideAjax('UserUtils'); //name of Script Include
ga.addParam('sysparm_name', 'getUsers'); //name of function
ga.addParam('sysparm_user', g_form.getValue('v_users'); //list collector variable name
ga.getXMLAnswer(function(answer){
confirm('Do you want to continue for ' + answer + '?');
});
}
Script Include with Client callable box checked
var UserUtils = Class.create();
UserUtils.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getUsers: function() {
var answerArr = [];
var users = this.getParameter('sysparm_user');
var gr = new GlideRecord('sys_user');
gr.addQuery('sys_id', 'IN', users);
gr.query();
while (gr.next()) {
answerArr.push(gr.name);
}
return answerArr.join(', ');
},
type: 'UserUtils'
});
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2023 04:03 AM
you need to use GlideAjax here which is synchronous. What's the requirement here to show the confirm box with the same values again to user?
Remember synchronous GlideAjax doesn't work directly in portal
Refer these links for workaround/solution on how to use Synchronous GlideAjax in onSubmit
How To: Async GlideAjax in an onSubmit script
Asynchronous onSubmit Catalog/Client Scripts in ServiceNow
If my response helped please mark it correct and close the thread so that it benefits future readers.
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-06-2023 10:35 PM
Thank You