Setting field values on onclick of New button on related list
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-16-2017 05:09 AM
Hello,
Can anyone let me know how to pass values on to the table fields after clicking New button on the Related List?
Example:
On the INcident form, I have added a related list Incident Task and when I click on INcident Task related list's New button, I want to have the caller field of the Incident to be copied and set automatically on the opened Incident Task form.
Thanks!
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-16-2017 05:15 AM
You need to create a New UI action with Name: "New", override the Global New Related List UI action.
Keep the condition as: (new GlideRecord(current.getTableName())).canCreate() && !RP.getListControl().isOmitNewButton() && RP.isRelatedList() && current.getTableName() == 'incident_task'
and in the script, you can set values:
current.caller_id=current.parent.caller_id;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-16-2017 11:12 PM
Anurag,
I have done the below, but it's not working:
1. Created another Global UI Action with Condition as
(new GlideRecord(current.getTableName())).canCreate() && !RP.getListControl().isOmitNewButton() && RP.isRelatedList() && current.getTableName() == 'incident_task'
and with script as
current.assigned_to=current.parent.assigned_to;
In the Overrides field, I have selected the New UI Action that applicable on my related list.
Please let me know my mistake.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-16-2017 11:41 PM
Ok 2 things, have you set the Action same as overridden new button?
If yes, try keeping the table of new button as Incident Task instead of Global and remove the 'current.getTableName() == 'incident_task'' condition.
Next, is the parent field being set as parent incident?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-16-2017 11:16 PM
Hello Janrameez,
Refer the below link may helpful to you.
http://wiki.servicenow.com/index.php?title=Creating_Defined_Related_Lists#gsc.tab=0
https://www.servicenowguru.com/system-definition/relationships/defined-related-lists/
ServiceNow Commnunity MVP -2018 class.