Autopopulate reference from parent record to cild record

Yamja
Tera Guru

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.

1 ACCEPTED SOLUTION

@Yamja 

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.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

3 REPLIES 3

Ankur Bawiskar
Tera Patron
Tera Patron

@Yamja 

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;

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Yamja
Tera Guru

Hi Ankur,

 

I have parent record, below is the screenshot.

Yamja_0-1681933672751.png

 

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.

Yamja_1-1681933855146.png

I don't have parent field name as "parent". Please provide me script for that if possible.

Thank You.

@Yamja 

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.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader