- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-11-2017 03:12 PM
Running this exact code the count is always coming back as 500, but it should be > 2454 records. If I look at the table the count is
Any insight as to why this isn't returning the full set of names would be appreciated.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading ) {
return;
}
var idz = getDepts();
}
function getDepts() {
var gr = new GlideRecord('u_badg_somrollup');
gr.addQuery('u_deptname' );
gr.query();
var deptNames =[];
i=-1;
while(gr.next()) {
i++;
deptNames[i]=gr.u_deptname;
}
alert ("Returned Count: " + deptNames.length); // 500
return deptNames;
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-12-2017 01:22 AM
Glenn, your query uses the following WHERE clause:
gr.addQuery('u_deptname' );
Without a value there it means WHERE clause would be something like:
SELECT * FROM u_badg_somrollup WHERE u_deptname IS NULL;
Is this something you wanted on purpose?
Running this in Background scripts should give you the exact count you are getting:
var gr = new GlideRecord('u_badg_somrollup');
gr.addQuery('u_deptname' );
gr.query();
gs.print(gr.getRowCount());
If you had in mind a value for "u_deptname" the your query should look like:
gr.addQuery('u_deptname', <value>);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-11-2017 03:19 PM
Hello Glenn,
Can you provide some additional details on what you are trying to accomplish? Details are encouraged.
As a best practice, use GlideAjax calls for server-side calls. GlideRecord calls are not recommended from the client side.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-11-2017 03:35 PM
I am trying to create a department selection field and a division selector in a record producer, which list only unique departments from a dept/division table that looks like this:
[
dept1 div1
dept1 div2
dept2 div3
dept2 div3
dept3 Null
dept4 div5
...
dept4 div54
...
]

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-11-2017 03:43 PM
Thanks for the update Glenn. In this case create a script include(client callable) and filter out the records per your logic and send back sysid as a response. Please check the example from below link as a reference and adjust it accordingly.
http://wiki.servicenow.com/index.php?title=Reference_Qualifiers
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-12-2017 01:22 AM
Glenn, your query uses the following WHERE clause:
gr.addQuery('u_deptname' );
Without a value there it means WHERE clause would be something like:
SELECT * FROM u_badg_somrollup WHERE u_deptname IS NULL;
Is this something you wanted on purpose?
Running this in Background scripts should give you the exact count you are getting:
var gr = new GlideRecord('u_badg_somrollup');
gr.addQuery('u_deptname' );
gr.query();
gs.print(gr.getRowCount());
If you had in mind a value for "u_deptname" the your query should look like:
gr.addQuery('u_deptname', <value>);