Create a child case from Parent case

Vamshi Krishna2
Tera Contributor

Hi,

I'm trying to populate parent case values to child case using the business rule but here the issue both the parent case and child case are from the same table but the below code is not working. 

In the child case, we have parent case no as below.

VamshiKrishna2_1-1672903634642.png

 

 

 

VamshiKrishna2_0-1672903559983.png

code

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

// Add your code here
var gr = new GlideRecord('sn_customerservice_case');
gr.initialize();
gr.parent = current.sys_id;
gr.short_description = current.short_description;
gr.description = current.description;
gr.assigned_to = current.assigned_to;
gr.state = current.state;
gr.category = current.category;
gr.priority = current.priority;
gr.insert();

})(current, previous);

3 REPLIES 3

Ashish21
Giga Expert

Hi Vamshi,

Please change the query to after business rule and try.

Please accept the solution if it solves your query.

 

Thanks,

Ashish

Hi Ashish, I tried but it's not working.

Aman Kumar S
Kilo Patron

Hi @Vamshi Krishna2 ,

What is your requirement, could elaborate further?

What I am seeing here, you are just creating a new record, whenever there is an existing record "abc" with some parent lets say "xyz", it will just create a new child record, with the parent set as "abc".
What exactly is the business use case here?

And what is selected for insert/update/query/delete?

 

Best Regards
Aman Kumar