- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-26-2012 09:27 AM
Hi,
I have a table cmdb_ci_computer which extends cmdb_ci table. In one of the email notifications, I am tryign to get the fields from cmdb_ci and 2 feilds from cmdb_Ci_compter( which is a child of cmdb_ci)
var gr = new GlideRecord("cmdb_ci");
gr.addQuery('assigned_to', current.requested_for);
gr.query();
while(gr.next()) {
if(gr.sys_class_name == 'cmdb_ci_computer')
{
template.print("Employee has "+gr.sys_class_name.getDisplayValue()+ "\n");
template.print("Form factor "+gr.cmdb_ci_computer.form_factor+ "\n"); // this is computer_ci_computer table
template.print("Asset Tag "+gr.asset_tag+ "\n"); //This cmdb_ci field//
template.print("------------------------\n");
}
}
I am trying to access form factor from amdb_ci_computer. I know I can do one more glide query, but can I do with dot walking to child table?
Thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-26-2012 09:50 AM
You can't just dotwalk, unfortunately. But if you have a GlideRecord gr for the base table (cmdb_ci), you can do the following to get a GlideRecord for the extension table, where you'll have access to the extension table's fields:
var gr2 = new GlideRecordUtil().getGR(gr.sys_class_name, gr.sys_id);
GlideRecordUtil is a Script Include.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-26-2012 09:50 AM
You can't just dotwalk, unfortunately. But if you have a GlideRecord gr for the base table (cmdb_ci), you can do the following to get a GlideRecord for the extension table, where you'll have access to the extension table's fields:
var gr2 = new GlideRecordUtil().getGR(gr.sys_class_name, gr.sys_id);
GlideRecordUtil is a Script Include.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-26-2012 10:56 AM
Thanks a lot..it worked.. But can you please clarify if dot wlaking is only possible if it a reference field. Here it was not possible beacuse this is child parent relationship.
Is my understanding correct.
Thanks a lot for the help..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-26-2012 11:55 AM
I believe your understanding is correct. You can dotwalk through a reference field, since the reference grabs the actual GlideRecord for the extension table.
Since the GlideRecord gr in your example was on the base table, however, base table fields are all you get without the extra step.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-10-2014 09:04 AM
I know this post is old, but just for reference, there actually is a way to dotwalk this stuff by using the "ref_" technique, you could do:
gr.ref_cmdb_ci_computer.form_factor