Parent incident to child incident
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-24-2024 10:19 PM
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.
- Labels:
-
Incident Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-24-2024 10:23 PM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-25-2024 03:53 AM - edited 10-25-2024 03:54 AM
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:
"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