
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-28-2019 07:14 AM
Hello,
I am trying to order by a field on a record I'm referencing within a function. The field cmdb_ci_service is a reference field on the task_cmdb_ci_service table but I want to order by a field that is on the cmdb_ci_service record. Has anyone successfully done this? Doesn't seem to be working for me. Below is a code snippet from my script. This works if I want to order by the cmdb_ci_service but won't work when dot walking and trying to order by to the u_business_service_tier.
insertBS();
function insertBS() {
var ubus = new GlideRecord('task_cmdb_ci_service');
ubus.addQuery('task', current.sys_id);
ubus.orderBy('cmdb_ci_service.u_business_service_tier');
ubus.query();
Any suggestions?
Thanks in advance.
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-01-2019 07:19 AM
Yea, not sure bud. I'm still looking around to see and I can sort of get why...but yea...seems unfortunate. The only thing I can think of as a sort of "band-aid" fix...is to create a similar field on your table (so now not dot-walking) and use an onAfter BR on the other table to copy the value in to your table's new field. Just to be able to sortBy it...tedious I know, but that's an option.
Please mark reply as Helpful/Correct, if applicable. Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-28-2019 08:03 AM
What kind of field is u_business_service_tier?
The following works on incident
var ubus = new GlideRecord('incident');
ubus.orderBy('caller_id.company.name');
ubus.query();
while(ubus.next())
{
gs.info(ubus.caller_id.company.name + "****" + ubus.number );
}
Vinod Kumar Kachineni
Community Rising Star 2022

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-28-2019 08:18 AM
u_business_service_tier is just a string field (drop down) with 4 choices. (tier_a, tier_b, tier_c, tier_d).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-28-2019 08:34 AM
Try with an encoded query
var ubus = new GlideRecord('incident');
ubus.addEncodedQuery('ORDERBYcaller_id.time_zone');
ubus.query();
while(ubus.next())
{
gs.info(ubus.number + " ** " + ubus.caller_id.name + " ** " + ubus.caller_id.time_zone);
}
Vinod Kumar Kachineni
Community Rising Star 2022

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-01-2019 07:13 AM
Unfortunately I received the same results using the encoded query. Seems like there has to be a way to do this, straightforward situation.