- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-18-2023 08:27 PM
Hi,
I have a requirement that, the child record reference field should auto fill with reference field in parent record.
I have two tables Div(parent table), Portfolio(child table). I have "business" field in both parent and child table. when I create a child from parent record, the "business" field in the child record need to auto-populate same as parent(business).
Please let me know anyone how can I achieve and the script.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-19-2023 08:08 PM
that was just the syntax; logic by adding proper field needs to be done by you
Replace the correct fields in bold below in Before insert BR on Portfolio table
Condition: current.u_FieldWhichRefersDivision != ''
Script:
current.u_childTable_businessUnitField = current.u_FieldWhichRefersDivision.u_parentBusinessFieldName;
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-18-2023 08:46 PM
why to have separate field on child?
You can show the parent field on child form using dot walking.
If this is still required then you can use before insert BR on child table
Condition: Parent IS NOT EMPTY
Script:
current.u_business = current.parent.u_business;
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-19-2023 12:51 PM
Hi Ankur,
I have parent record, below is the screenshot.
In the related list I have portfolio, when I am trying to create new portfolio , I need to populate that business unit from parent. please find the screenshot for current process.
I don't have parent field name as "parent". Please provide me script for that if possible.
Thank You.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-19-2023 08:08 PM
that was just the syntax; logic by adding proper field needs to be done by you
Replace the correct fields in bold below in Before insert BR on Portfolio table
Condition: current.u_FieldWhichRefersDivision != ''
Script:
current.u_childTable_businessUnitField = current.u_FieldWhichRefersDivision.u_parentBusinessFieldName;
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader