Copying parent complaint case values to child complaint case

JordyZ
Mega Sage

Hi,

I'm trying to copy all field values from parent complaint case to child complaint case with this display business rule:

 

 

    if (current.isNewRecord())
    current.requesting_service_organization = current.parent.requesting_service_organization;
    current.u_agency_worker = current.parent.u_agency_worker;
    current.u_agency_worker_name = current.parent.u_agency_worker_name;
    current.account = current.parent.account;
    current.u_iban_account_number = current.parent.u_iban_account_number;
    current.consumer = current.parent.consumer;

 

 However, when I activate the script, all the parent values of the complaint case disappear.

JordyZ_0-1716465004938.png

When I deactivate the business rule, the values are back again.

JordyZ_1-1716465094443.png

 

When I create a child complaint case from the parent, it does copy over all the values, despite the values being "empty" in the parent case.

 

What can I do to fix the "empty" parent case values?

 

Thanks in advance.

1 ACCEPTED SOLUTION

Kieran Anson
Kilo Patron

Hi,

I'd move your validation condition to the condition field.

 

 

current.isNewRecord() && !current.parent.nil()

 

 

 

(function executeRule(current, previous /*null when async*/) {

	var fieldsToCopy = ["consumer","u_iban_account_number","account","u_agency_worker_name","u_agency_worker","requesting_service_organization"]; //Store as a system property

		var parentRecordGR = current.getElement('parent').getRefRecord();

	fieldsToCopy.forEach(function(field){
		current.setValue(field , parentRecordGR.getValue(field));
	})
})(current, previous);

 

View solution in original post

6 REPLIES 6

Hi @nowitsvashu , yes I corrected that typo but it's still not working. Could you check my edited response above to see if I did anything wrong? Thanks in advance.

I tested this on incident and it worked fine

(function executeRule(current, previous /*null when async*/) {

	var fieldsToCopy = ["caller_id", "assigned_to" , "assignment_group" , "impact" , "urgency"]; //Store as a system property

	var parentRecordGR = current.getElement('parent').getRefRecord();

	fieldsToCopy.forEach(function(field){
		current.setValue(field , parentRecordGR.getValue(field));
	})

})(current, previous);