How to get parent major case values to child case before clicking on the submit button
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2024 02:47 AM
Hi Team,
How to get parent major case values to child case before clicking on the submit button.
Requirement:
On the major case form we have a related list called "child cases". After Clicking on the New button on the child cases case form will open. If we click on submit ui action, after form saves all the parent case values will capture in the child case, this is OOTB functionality.
But I want to populate parent case values, before submitting the child case form.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2024 09:16 AM
@Gopal14 On the create new case form, if you have access to the parent case (via a reference field) then you can create an onLoad script and use g_form.getReference to fetch all the details of the parent case and pre-populate them on the form using g_form.setValue().
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2024 10:28 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2024 11:57 PM - edited 05-20-2024 11:59 PM
Hi @Gopal14,
This can be achieved like below code:
Create one Script Include:
var AutoFillData = Class.create();
AutoFillData.prototype = {
initialize: function() {},
autoFillData: function() {
var syID = gs.getParameter('sysparm_sysID');
var obj = {};
var inc = new GlideRecord('incident');
inc.addQuery('parent_incident', syID);
inc.query();
if (inc.next()) {
obj.short_description = inc.short_description;
obj.description = inc.description;
return JSON.stringify(obj);
}
},
type: 'AutoFillData'
};
Create onLoad Client script below:
function onLoad() {
//Type appropriate comment here, and begin script below
var sysID = g_form.getUniqueValue();
var inc = new GlideAjax('AutoFillData');
inc.addParam('sysparm_name','autoFillData');
inc.addParam('sysparm_sysID', sysID);
inc.getXML(callBack);
function callBack(response){
var comments = response.responseXML.documentElement.getAttribute("answer");
var data = JSON.parse(comments);
g_form.setValue('short_description', data.short_description);
g_form.setValue('description', data.description);
}
}
Note: I have created this for parent child Incident. You can replace the table name in GlideRecord.
Please accept the solution if it works for you.
Thanks
Jitendra