Dot-walking in a GlideRecord addQuery()

Meloper
Kilo Sage

Ist that Possible?

check();

function check() {
    var gr = new GlideRecord("hr_case");
	gr.addActiveQuery();
	gr.addQuery('parent.template', '16c971f9db58ec14066c4f63059619b8');
	gr.query();
	gr.next();
		gs.info(gr.parent.template);
}
1 ACCEPTED SOLUTION

check();

function check() {


    var gr = new GlideRecord("hr_case");
    gr.addActiveQuery();
    gr.addQuery('parent.ref_sm_order.template', '16c971f9db58ec14066c4f63059619b8');
    gr.query();
    gr.next();
    gs.log(gr.number);
}

View solution in original post

14 REPLIES 14

Mark Roethof
Tera Patron
Tera Patron

Hi there,

Yes that should be possible.

Are you running into any issues?

If my answer helped you in any way, please then mark it as helpful.

Kind regards,
Mark
2020 ServiceNow Community MVP
2020 ServiceNow Developer MVP

---

LinkedIn
Community article list

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

Yes with this example 😉

I tested it wiht a Fix Sript.

Error ist to long to copy

 

I have also heard that if an error occurs, too many GR elements could be created

So can you see anything in that error? For example table hr_case might be incorrect. I would expect sn_hr_case or sn_hr_core_case.

Also double check the template sys_id.

If my answer helped you in any way, please then mark it as helpful.

Kind regards,
Mark
2020 ServiceNow Community MVP
2020 ServiceNow Developer MVP

---

LinkedIn
Community article list

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

@Meloper 

this should work fine

Can you try to use if(gr.next()) in order to print the value

check();

function check() {
    var gr = new GlideRecord("sn_hr_core_case");
    gr.addActiveQuery();
    gr.addQuery('parent.template', '16c971f9db58ec14066c4f63059619b8');
    gr.query();
    gr.next();
    if(gr.next()){
        gs.info(gr.parent.template);
    }
}

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader