- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2023 01:51 PM
Hi,
I have created a UI action(Incident) in the Problem table. When Incident button is clicked then the List of Incident table is coming up.
Now I created one more UI Action Add to Incident in the List choice.(Actions on selected rows)
The requirement is that we can select the multiple choices from the incident list and once we select the Add to Incident then in all the selected Incidents Problem number should added or autopopulate.
Please help in this.
Thanks!
Samiksha
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2023 09:10 PM
Hi @Samiksha2
Sorry for the late reply. Got your query and just now tried in my instance and it worked as you expected.
In the Add to Incident UI action use below logic:
function downloadattachment() {
var getSysId = g_form.getUniqueValue(); //will return current sys_id/ problem sys_id
var getRec = g_list.getChecked(); //will return checked record sys_id's in list view
if (getRec.length > 0) {
var ajax = new GlideAjax("global.Newglidingabc");
ajax.addParam("sysparm_name", "updatePRinINC");
ajax.addParam("sysparm_arr", getRec);
ajax.addParam("sysparm_prb", getSysId);
ajax.getXMLAnswer(callbackdata);
}
function callbackdata(response) {
var answer = response;
if (answer == "done") {
alert("Updated successfully");
GlideDialogWindow.get().destroy(); //closes the dailog window after updation
}
}
}
Script include:
updatePRinINC: function() {
var grI = new GlideRecord("incident");
grI.addQuery("sys_id", "IN", this.getParameter("sysparm_arr")); //checked list
grI.query();
while (grI.next()) {
grI.problem_id = this.getParameter("sysparm_prb"); //problem sys_id
grI.update();
}
return "done";
},
type: 'Newglidingabc'
});
(=tested)
Hope it helps.
Murthy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2023 02:43 PM
Hi @Samiksha2
Are you using OOB Ui action or custom one which you created?
If custom one please share the script once.
Murthy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2023 10:49 PM - edited 01-19-2023 11:11 PM
Hi @Murthy Ch
I have created the UI action.
onCLick- getIncident()
Script:
function getIncident() {
var w = new GlideDialogWindow('show_list');
w.setTitle('Select Incident');
w.setPreference('table', 'incident_list');
w.setPreference('sysparm_view', 'default');
w.render();
}
Another UI action is
When user multiselect the incident record, problem number will update in all the selected incidents.
Like this
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2023 09:10 PM
Hi @Samiksha2
Sorry for the late reply. Got your query and just now tried in my instance and it worked as you expected.
In the Add to Incident UI action use below logic:
function downloadattachment() {
var getSysId = g_form.getUniqueValue(); //will return current sys_id/ problem sys_id
var getRec = g_list.getChecked(); //will return checked record sys_id's in list view
if (getRec.length > 0) {
var ajax = new GlideAjax("global.Newglidingabc");
ajax.addParam("sysparm_name", "updatePRinINC");
ajax.addParam("sysparm_arr", getRec);
ajax.addParam("sysparm_prb", getSysId);
ajax.getXMLAnswer(callbackdata);
}
function callbackdata(response) {
var answer = response;
if (answer == "done") {
alert("Updated successfully");
GlideDialogWindow.get().destroy(); //closes the dailog window after updation
}
}
}
Script include:
updatePRinINC: function() {
var grI = new GlideRecord("incident");
grI.addQuery("sys_id", "IN", this.getParameter("sysparm_arr")); //checked list
grI.query();
while (grI.next()) {
grI.problem_id = this.getParameter("sysparm_prb"); //problem sys_id
grI.update();
}
return "done";
},
type: 'Newglidingabc'
});
(=tested)
Hope it helps.
Murthy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2023 11:34 PM
Thank you so much @Murthy Ch . I was waiting for your reply.😀