I want to add a record to a related list via script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2019 01:35 PM
I have a variable (referencing: cmdb_ci_computer) on a catalog item, and I would like to add the referenced computer to the "affected CIs" related list on the requested item record. I don't know how to refer to the related list in my script.
Specific use case ... after the last task in the requested item workflow is completed, I want to make the entry to the appropriate related list on the RITM being completed.
Thanks!
- Labels:
-
Service Desk

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2019 01:58 PM
Hi Jon,
You can refer to the Related List using a GlideRecord query. Look at the code in this post- https://community.servicenow.com/community?id=community_question&sys_id=35c7cbe9db1cdbc01dcaf3231f96...
Please mark my answer helpful/correct based on the impact.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2019 02:23 PM
Hi Priyanka,
Thanks for your response. I'm having trouble relating your example to my use case. Not sure why I would need a glide query ... the related list I'm interested in is on the "current" record (this script is executing in workflow associated with that record). And the record I want to add to the related list is represented by a variable on "current." so, it seems like it should be able to refer the list as something like:
current.relatedList ... I just don't know how to figure out the "name" of a given related list??
Thanks again,
Jon

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2019 02:27 PM
Hey Jon,
Can you go to System UI -> Related Lists and check if you see your RL there?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2019 02:31 PM
Try to get the related_list_table_name from the list control of the related list. Right click related list header > Personalize/Configure List Control. Copy the value from the field 'Related list'.