- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-09-2023 09:03 AM
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
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2023 01:19 AM
@Alextia ,
Filter Navigator -> system logs -> All
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-09-2023 09:38 AM
Probably something wrong with your code, cause the scenario is valid.
So share your code so people can debug ti.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-09-2023 09:45 AM
@Alextia ,
This scenario is completely valid, as you can see in the incident table we have a parent incident field which refers to incident table itself, only thing which you have missed is when you create the field please perform this configurations
This will work 100%
If my answer solved your issue, please mark my answer as ✅Correct & 👍Helpful based on the Impact.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-09-2023 09:14 PM
Hi,
Thank you for the reply
I tried with above settings but still its not returning the value.
here is my code:
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();
if (tax_node.next()){
s += tax_node.parent.name + ',';
}
return 'nameIN' + s;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-09-2023 10:56 PM
@Alextia ,
I have tried the same scenario in my PDI and I was not able to access the reference field before the configurations and after making these changes user was accessible for me. For the confirmation you can try below script in background script like you will get Idea whether it is working or not
var gr = new GlideRecord("sys_user");
gr,get("SYS_ID_OF_USER");
gs.info(gr.YOUR_FIELD_NAME.name);
Now if we talking about your script, I am not aware of the business logic of your scenario, but yes for debugging purpose, can you add gr.getRowCount() in the script just got to know whether you receive any information after applying the filter.
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.name + ',';
}
return 'nameIN' + s;
if the above log is returning 0 as output, please check you applied filters their might be some issues in that.
If my answer solved your issue, please mark my answer as ✅Correct & 👍Helpful based on the Impact.