Parent and Child Script within Relationship Types
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-29-2009 08:48 AM
We have been leveraging the cmdb Related Items field withing incident and change within our instance.
Using the task relationships application I have set several different relationship types. Within those types are two fields called "parent script" and "child script".
I have been trying to pass values in the parent task to the child task within these fields but have been unsuccessful.
The code I have been using is:
child.u_value = parent.u_value;
This does not seem to be working. Does anyone have experience passing values within the related item field?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-29-2009 05:52 PM
Where are you running the script, and what object are you trying to update? what you do changes based on the relative location of the script.
You will probably have to do a GlideRecord query to return the object you want to update, like so:
var gr = new GlideRecord('parents_table');
gr.addQuery('sys_id',current.parent);
gr.query();
if(gr.next()){
gr.field_value = current.field_value;
gr.update();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-29-2009 08:49 PM
You can also dot-walk as parent is a reference:
current.parent.u_value
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-03-2011 12:48 PM
For others like me who don't know what a dot-walk is, see this wiki:
http://wiki.service-now.com/index.php?title=Dot-Walking