Parent incident to child incident

Hitesh Ramba
Tera Contributor

On a incident form in the related lists there is Child incident . When we click on New button on child incident the description of the parent incident must auto populate on the child incident New form.

 

How can we achieve this functionality.

 

Thanks

Hitesh.

2 REPLIES 2

Amit Verma
Kilo Patron
Kilo Patron

Hi @Hitesh Ramba  

 

Refer https://www.servicenow.com/community/itsm-forum/copy-values-from-parent-to-child-incident/m-p/699695

 

Thanks and Regards

Amit Verma


Please mark this response as correct and helpful if it assisted you with your question.

Juhi Poddar
Kilo Patron

Hello @Hitesh Ramba  

 

When the "New" button is clicked on the Child Incidents related list of a parent incident, a new incident form opens. The URL of this form includes the sysparm_collectionID parameter, which contains the sys_id of the parent incident record.

To automatically populate the Description field on the child incident with the parent incident’s description, we can create an onLoad client script on the incident table. The following script checks if the record is new and then retrieves the parent’s description:

 

function onLoad() {
   // Check if the form is a new record
   if (g_form.isNewRecord()) {
       // Retrieve the parent sys_id from the URL parameter
       var parentSysId = g_request.getParameter("sysparm_collectionID");

       if (parentSysId) {
           // Query the parent incident record
           var parentIncident = new GlideRecord('incident');
           if (parentIncident.get(parentSysId)) {
               // Populate the child incident's description with the parent's description
               g_form.setValue('description', parentIncident.description);
               // Additional fields can be populated similarly if needed
           }
       }
   }
}

 

This script checks if a new record is being created, retrieves the parent incident record using the sys_id from sysparm_collectionID, and then sets the Description field on the child incident form to match the parent’s description.

Preview of client script:

JuhiPoddar_0-1729853546051.png

 

"If you found my answer helpful, please give it a like and mark it as the accepted solution. It helps others find the solution more easily and supports the community!"

 

Thank You

Juhi Poddar