How to pass a Parent sys_id into related list "New" record in a field

Aldo Andrade1
Giga Expert

Hi ServiceNow Community,

 

I want to pass the Parent sys_id into related list "New" record in a field,

 

I have a Training table where each record has related list table that points to a Time Entries table,

When I click on that Time Entries "New" button, I need to have the Training parent record ID in there so I can make relationship between them.

tempsnip.png

Time Entry.jpg

 

I need to have that parent sys_id in a reference field called "training" from that Time Entrie table.

 

How can I do that without using AjaxCall or server side call?

 

 

1 ACCEPTED SOLUTION

Aldo Andrade1
Giga Expert

Hi Swarnadeep,

 

The situation is that it was necessary to build a new Relationship (it does not existed before) so it was not populating by default this data when clicking in New,

 

I found a solution. It was necessary to add on that Relationship the "Insert callback" code:

 

current.u_training = parent.sys_id;
current.update();
 
With this data its making the relationship update.

View solution in original post

2 REPLIES 2

SwarnadeepNandy
Mega Sage

Hello @Aldo Andrade1,

I think if you define the related list properly form the Configure > Related List and you can see the related list filter, it happens automatically.

So, with a properly defined related list, you can click on "New" and Time Entries record will auto populate with Training record.

 

Kind Regards,

Swarnadeep Nandy

Aldo Andrade1
Giga Expert

Hi Swarnadeep,

 

The situation is that it was necessary to build a new Relationship (it does not existed before) so it was not populating by default this data when clicking in New,

 

I found a solution. It was necessary to add on that Relationship the "Insert callback" code:

 

current.u_training = parent.sys_id;
current.update();
 
With this data its making the relationship update.