
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-04-2019 11:13 AM
I have a situation where multiple records can be selected and then a List UI Action can be invoked. I am passing the list of sys_ids from getChecked() to GlideAjax to be processed on the Server Side. I am matching records from multiple tables and getting a value from the second table. It is a true/false field.
IF the answer comes back false, then a UI Page will be invoked for input and update of the selected records.
IF the answer comes back true, then I need to pop a message so that the selected records can not be updated.
This is all working unless I select multiple records and the answer for those records differs.
I think I need to return JSON to the UI Action Client Side and then Parse somehow to see if "true" exists in order to pop the message...but the somehow evades me!!!
Any assistance would be most helpful. Thanks!!
Here is the current Client Script:
function Prevent_Remove() {
tblName = g_list.getTableName();
selSysIds = g_list.getChecked();
var selected_sys_ids = g_list.getChecked();
var ajax = new GlideAjax("mustInclude");
ajax.addParam("sysparm_name","delMustInclude");
ajax.addParam("selected_sys_ids", selected_sys_ids);
ajax.getXML(removeIt);
}
function removeIt (response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
alert('The Answer is set to: ' +answer);
if(answer == 'false') {
// Initialize and open the Dialog Window
var dialog = new GlideDialogWindow("slc_remove_dialog_window");
dialog.setTitle('Choose your removal reason');
dialog.setPreference("selected_sys_ids", selSysIds);
dialog.setSize(400,300);
dialog.render(); //Open the dialog
}
else{
alert('You have chosen a Deliverable which can not be removed');
}
}
Here is the current Script Include:
var mustInclude = Class.create();
mustInclude.prototype = Object.extendsObject(AbstractAjaxProcessor, {
delMustInclude : function () {
var sys_ids = this.getParameter('selected_sys_ids');
var m2m_deliverablesGR = new GlideRecord('u_slc_m2m_deliverables');
m2m_deliverablesGR.addQuery('sys_id', 'IN', sys_ids);
m2m_deliverablesGR.query();
while(m2m_deliverablesGR.next()){
var m2m_del = m2m_deliverablesGR.u_slc_deliverables.getDisplayValue();
//I need to get / match information from a separate table
var slc_deliverableGR = new GlideRecord('u_slc_deliverables');
slc_deliverableGR.get('u_name', m2m_del);
slc_deliverableGR.query();
var delName = slc_deliverableGR.u_name;
var mi = slc_deliverableGR.u_slc_must_include;
while(slc_deliverableGR.next()){
if(mi == true){
return true;
}
else {
return false;
}
}
}
},
type: 'mustInclude'
});
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-04-2019 12:32 PM
I figured it out!!!! I was only processing the first record that came back as true and then exiting/returning out of my while...
Script Include changed as follows for the fix:
var mustInclude = Class.create();
mustInclude.prototype = Object.extendsObject(AbstractAjaxProcessor, {
delMustInclude : function () {
var flag2send = false;
var sys_ids = this.getParameter('selected_sys_ids');
var m2m_deliverablesGR = new GlideRecord('u_slc_m2m_deliverables');
m2m_deliverablesGR.addQuery('sys_id', 'IN', sys_ids);
m2m_deliverablesGR.query();
while(m2m_deliverablesGR.next()){
var m2m_del = m2m_deliverablesGR.u_slc_deliverables.getDisplayValue();
//I need to get / match information from a separate table
var slc_deliverableGR = new GlideRecord('u_slc_deliverables');
slc_deliverableGR.get('u_name', m2m_del);
slc_deliverableGR.query();
var delName = slc_deliverableGR.u_name;
var mi = slc_deliverableGR.u_slc_must_include;
while(slc_deliverableGR.next()){
if(mi == true){
flag2send = true;
}
}
}
return flag2send;
},
type: 'mustInclude'
});

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-04-2019 11:19 AM
Have you checked what value are you getting in 'sys_ids' in 'Script Include' when you select multiple?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-04-2019 12:34 PM
Thanks for jumping in and trying to help. But I figured it out in a much simpler way than I thought I was going to have to do...

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-04-2019 12:41 PM
Cool, thats good.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-04-2019 12:32 PM
I figured it out!!!! I was only processing the first record that came back as true and then exiting/returning out of my while...
Script Include changed as follows for the fix:
var mustInclude = Class.create();
mustInclude.prototype = Object.extendsObject(AbstractAjaxProcessor, {
delMustInclude : function () {
var flag2send = false;
var sys_ids = this.getParameter('selected_sys_ids');
var m2m_deliverablesGR = new GlideRecord('u_slc_m2m_deliverables');
m2m_deliverablesGR.addQuery('sys_id', 'IN', sys_ids);
m2m_deliverablesGR.query();
while(m2m_deliverablesGR.next()){
var m2m_del = m2m_deliverablesGR.u_slc_deliverables.getDisplayValue();
//I need to get / match information from a separate table
var slc_deliverableGR = new GlideRecord('u_slc_deliverables');
slc_deliverableGR.get('u_name', m2m_del);
slc_deliverableGR.query();
var delName = slc_deliverableGR.u_name;
var mi = slc_deliverableGR.u_slc_must_include;
while(slc_deliverableGR.next()){
if(mi == true){
flag2send = true;
}
}
}
return flag2send;
},
type: 'mustInclude'
});