- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-17-2021 11:29 AM
Hello,
I need a UI Action that will allow a user to select 1 or many records and then open a comments dialog modal . The comments modal will update all selected records with the comment entered. How can I do this?
***EDIT***
I've figured out how to do this through Alerts and Prompts, but I want to do this using GlideModal and UI Page. Can someone help me figure out how to reconstruct what I have?
UI Action:
function getRecords() {
var oldVal = '';
var selectedRecords = g_list.getChecked();
var prompt = prompt("Enter a Comment Here: ", oldVal);
if (!selectedRecords|| selectedRecords.length == 0)
return;
if (prompt!= '' && prompt!= null) {
var ga = new GlideAjax('GetRecordsSelected');
ga.addParam('sysparm_name', 'getSelectedRecords');
ga.addParam('sysparm_ids', selectedRecords);
ga.addParam('sysparm_prompt', prompt);
ga.getXML(getRec);
} else {
alert("Please input a comment");
}
function getRec(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
location.reload();
}
}
Script Include:
var GetRecordsSelected = Class.create();
GetRecordsSelected.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getSelectedRecords: function() {
var array = [];
var selectedRecords = this.getParameter('sysparm_ids');
var prompt = this.getParameter('sysparm_prompt');
var sysIds = selectedRecords.split(",");
var gr = new GlideRecord('incident');
gr.addQuery('sys_id', 'IN', selectedRecords);
gr.query();
while (gr.next()) {
gr.short_description = prompt;
gr.state = '3'; //On Hold
gr.caller_id = 'Abel Tuter (architect)'; //Abel Tutter
gr.assignment_group = '019ad92ec7230010393d265c95c260dd'; //Analytics Settings Managers
gr.update();
}
},
type: 'GetRecordsSelected'
});
Thanks!
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-17-2021 07:56 PM
use this to pass variables to your UI Page
.setPreference('your_param','test');
Then you can use this code to set variables
<j:set var="jvar_your_param" value="${sysparm_your_param}"/>
And reference in client script by
'${JS:sysparm_your_param}'
ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-17-2021 11:43 AM
You can technically already do this by update selected UI context menu,
But to do what your doing you have to investigate a UI action that opens a modal window which will be set up under UI page and would have only the comments window.
Also another trick is the control trick hold control and click all the comments boxes you want to update let go control doubleclick one of the cells then type your comments in and all cells will be updated- you may not want to recreate something you have multiple ways of doing now
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-17-2021 11:52 AM
Thanks for your response
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-17-2021 06:08 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-17-2021 07:56 PM
use this to pass variables to your UI Page
.setPreference('your_param','test');
Then you can use this code to set variables
<j:set var="jvar_your_param" value="${sysparm_your_param}"/>
And reference in client script by
'${JS:sysparm_your_param}'
ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022