- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-02-2024 08:27 AM
Hi, I have a basic problem with my query. Unfortunately I don't know how to solve it.
I want to check the property WL (in the table u_systems) for the items selected in my ListCollector.
My idea was to get all items from ListCollector, create a special query and then collect all values for WL property for each row.
Problem is that this query doesn't work as it should be, it's not listing all rows as it should do.
Do you have any ideas?
Client Script - onChange - variable:ListCollector
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var ListCollector = g_form.getValue('ListCollector');
var ajax = new GlideAjax("get_data");
ajax.addParam("sysparm_name","getWL");
ajax.addParam("sysparm_system_name", ListCollector);
ajax.getXML(ajaxResponse);
function ajaxResponse(serverResponse) {
var answer = serverResponse.responseXML.documentElement.getAttribute("answer");
answer = JSON.parse(answer);
alert(answer);
}}
Script Include
getWL: function(){
var query = '';
var data;
var zbior = this.getParameter('sysparm_system_name');
var array = [];
array = zbior.split(",");
var gc = new GlideRecord("u_systems");
for (var i=0; i< array.length; i++) {
query += "sys_idLIKE" + array[i] + "^OR";
}
gc.addEncodedQuery(query);
gc.query();
if(gc.next()){
gs.log("WL" + gc.u_WL);
data += gc.u_WL;
}
return data;
},
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-02-2024 08:44 AM
1. Is your client script calling the script include? I suggest add an log message right at the top to verify it first.
2. I see your query might return multiple records, so we should be using while(gc.next())

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-02-2024 08:44 AM
1. Is your client script calling the script include? I suggest add an log message right at the top to verify it first.
2. I see your query might return multiple records, so we should be using while(gc.next())
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-03-2024 01:20 AM
Thank you, it worked after using "while(gc.next())".