The Zurich release has arrived! Interested in new features and functionalities? Click here for more

I want to add new record to related list using script

Arun_Manoj
Mega Sage

Hi,

 

I have requirement to map the reference field to related list for that record.

 

Risk event 
i have custom field citation takeplace --> reference field to citation

 

in that risk event i have related list also for ciitation

 

so, value in custom field citation needs to map to the citation related list

2 REPLIES 2

Omkar Kumbhar
Mega Sage
Mega Sage

Hello @Arun_Manoj ,

 

Create a custom relationship definition from System Definition > Relationships.

 

Below is sample example try modifiying it according to your requirement.

Applies to = "Incident"

Queries from: "your_custom_table" (Problem in this example)


As a script, you can do yours similar to the following: (Parent = Incident, Current = Problem) 

(function refineQuery(current, parent) {

	current.addQuery("sys_id", parent.problem_id); // Replace problem_id with your custom reference field

})(current, parent);

 

You can add then your custom related list to the incident form

 

OmkarKumbhar_0-1753948820137.png

 

 

If I was able to help you with your case, please click the Thumb Icon and mark as Correct.

moyec
Kilo Contributor

@Arun_Manoj wrote:

Hi,

 

I have requirement to map the reference field to related list for that record.

 

Risk event 
i have custom field citation takeplace --> reference field to citation

 

in that risk event i have related list also for ciitation

 

so, value in custom field citation needs to map to the citation related list


The most effective way to map a reference field to a related list is by using a server-side script, such as a Business Rule. This script should be configured to run after a record is updated, specifically when the reference field's value changes. The script's logic will then take the unique ID of the selected record from the reference field and automatically create a new entry in the table that populates the related list, thereby linking the two records.