how to get the value of a reference field which refers its table itself

Alextia
Giga Expert

Hi,

Actually I can't  get the value of a reference field (which refers its table itself )using Glide Record in Script include.

Is it because of same table itself added as reference field?

Ex.

Table1

name   parent(reference field ->Table1.name)

John  

Sam      John 

Mike   John

So, if I want to know the parent of mike, I suppose to use  Table1.parent.name but its not working.

can anyone let me know how we can handle this scenario?

 

Thanks

 

 

1 ACCEPTED SOLUTION

@Alextia ,

 

Filter Navigator -> system logs -> All

 

PRINCE_ARORA_0-1678439496686.png

 

 

Also in my previous reply I have mentioned pls try a small script in background script to get confirmation whether its working or not!

var gr = new GlideRecord("sys_user");

gr,get("SYS_ID_OF_USER");

gs.info(gr.YOUR_FIELD_NAME.name);

 

Also In your script can you try this : (I am assuming you are implementing reference qualifier on reference field of user table)

var tax_node = new GlideRecord('spm_taxonomy_node');
var tech_srv = tax_node.addJoinQuery('cmdb_ci_service_technical','name','spm_taxonomy_node.name'); tech_srv.addCondition('u_ci_id',current.variables.app_name_with_cmdb.u_ci_id);
tax_node.query();

gs.info("getRowCount() " + tax_node.getRowCount() );// add this for debugging purpose
if (tax_node.next()){
s += tax_node.parent+ ',';
}
return 'sys_idIN' + s;


 If my answer solved your issue, please mark my answer as Correct & 👍Helpful based on the Impact.

View solution in original post

7 REPLIES 7

@Prince Arora 

 

Query is working fine as retuning the value for tax_node.name instead of tax_node.parent.name.

May I know where I could see the output of gs.info() if I am using the catalog item?

 

@Alextia ,

 

Filter Navigator -> system logs -> All

 

PRINCE_ARORA_0-1678439496686.png

 

 

Also in my previous reply I have mentioned pls try a small script in background script to get confirmation whether its working or not!

var gr = new GlideRecord("sys_user");

gr,get("SYS_ID_OF_USER");

gs.info(gr.YOUR_FIELD_NAME.name);

 

Also In your script can you try this : (I am assuming you are implementing reference qualifier on reference field of user table)

var tax_node = new GlideRecord('spm_taxonomy_node');
var tech_srv = tax_node.addJoinQuery('cmdb_ci_service_technical','name','spm_taxonomy_node.name'); tech_srv.addCondition('u_ci_id',current.variables.app_name_with_cmdb.u_ci_id);
tax_node.query();

gs.info("getRowCount() " + tax_node.getRowCount() );// add this for debugging purpose
if (tax_node.next()){
s += tax_node.parent+ ',';
}
return 'sys_idIN' + s;


 If my answer solved your issue, please mark my answer as Correct & 👍Helpful based on the Impact.

Alextia
Giga Expert

@Prince Arora 

Thanks a lot for your help. Its working as expected when i used sys_id.

Cheers