Dot-walk, query, and get Document ID field value (sys_id)

Desmo
Mega Guru

Hello,

I'm trying to populate a reference field in a table using a business rule. OOB checklist macro--the one that controls what values go into the checklist_item record--only works on the task table.

I'm struggling to dot-walk and query a Document ID field from the checklist_item table to the checklist table.

var gr = new GlideRecord('checklist');
gr.addQuery('checklist_item.checklist.document','sys_id'); //Document ID field.
gr.query();
if (gr.next()) {

current.u_number = gr;

}

 

Thank you.

Desmo

1 ACCEPTED SOLUTION

Community Alums
Not applicable

Hey,

use .getRefRecord();

for ex :

var myDoc = current.checklist.getRefRecord();

current.u_number = myDoc.document + "";

 

No need to use GlideRecord this way

 

Cheers,

Joro

 

View solution in original post

2 REPLIES 2

sachin_namjoshi
Kilo Patron
Kilo Patron

Update your code like below

 

var gr = new GlideRecord('checklist_item');
gr.addQuery('checklist.document',current.sys_id); //Document ID field.
gr.query();
if (gr.next()) {

current.u_number = gr.<FIELD_FROM_CHECKLIST_TABLE>;

}

 

Regards,

Sachin

 

Regards,

Sachin

Community Alums
Not applicable

Hey,

use .getRefRecord();

for ex :

var myDoc = current.checklist.getRefRecord();

current.u_number = myDoc.document + "";

 

No need to use GlideRecord this way

 

Cheers,

Joro