I need to grab the current record's name and use it in a related list's UI action script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-18-2016 02:40 PM
I have a UI action on a related list that lives in a form. There's a "name" field in the form that I want to grab to be able to pass it to the UI Action's script. I cannot do "current.name" because that doesn't point to the object of the form but instead points to the related list's table. Is there any way to accomplish this? There is currently nothing relating the related list's records and the form so I can't do a GlideRecord and use a keyword to tie them together. Any help would be appreciated. Thanks.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-18-2016 03:09 PM
Using the Scratchpad should solve your problem its item 3.1 Client Script Best Practices - ServiceNow Wiki
...or a simplier approach you can do, related lists records all have a field called "parent" which you can confirm by clicking new on your related list, config>>form layout>> and then you should see a field called Parent. The related list record already has a reference to the parent on the form so you can then dot walk on the client side.
But there may be a different solution, can you clarify, what is the UI action in the related list, I am assuming its a custom one like "new" or "edit", suppose to do?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-18-2016 03:16 PM
The scratchpad passes from the server to the client, however, I need to grab the value in the form and use it in the UI Action's script. The Related list's UI Action is supposed to make a copy of the selected records and insert them with the name in the current form.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-18-2016 03:53 PM
Is this before the form is saved or after? Assuming its saved a simplier approach you can do, related lists records all have a field called "parent" which you can confirm by clicking new on your related list, config>>form layout>> and then you should see a field called Parent. The related list record already has a reference to the parent on the form so you can then dot walk on the client side.