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

Thanks for your help

@Meloper 

Reason being

1) parent field on HR Case refers to task table

2) the template field is present on sn_hr_core_case table so you cannot dot walk in the query

If you try to form the query from the filter it won't show the template field as well

Regards
Ankur

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

@Meloper 

From which scope you are running this.

Also did you check the HR case is active

Regards
Ankur

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

Pranav Bhagat
Kilo Sage

You can use Background scripts to test it .

I also see you are using table as hr_case, are you using legacy HR Application ?

 

Regards

Pranav

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

Is that HR Case Active?

Is the Parent HR Case for this case has template populated or not

Also from which scope you are running this script

Regards
Ankur

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