Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

Has anyone dot walked within an OrderBy command?

Chad27
Tera Expert

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.

1 ACCEPTED SOLUTION

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!

View solution in original post

8 REPLIES 8

Allen Andreas
Tera Patron

Hmm...it seems from another thread doing this very same thing, they weren't able to get this to work and I don't think it does.

https://community.servicenow.com/community?id=community_question&sys_id=238c8fa5db9cdbc01dcaf3231f96...

They tried various ways and just no luck it seems.

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

Allen - I saw this thread as well. Can't believe there isn't a way to do this. hmm.

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!

Allen - Appreciate the workaround. This worked and resolved our issue.