Copy field value from child to parent

arundharmabe
Tera Guru

Hi All,

I need help on the below requirement. At the moment when the incident is resolved there will be an incident task gets created. Here i want to copy the state of the incident task to a string field on incident table. Already i've tried with the Display BR it's working but it's not saving the value, I've tried with before / after BR but no luck. Can someone guide me on how i can achieve the same.

Below is the simple piece of code that i'm using inside the Display BR

var rec = new GlideRecord('incident_task');

rec.addQuery('incident', current.sys_id);

rec.query();

if (rec.next()) {

current.u_category_on_open = rec.state.getDisplayValue();

}

 

Regards,

Arun

1 ACCEPTED SOLUTION

Hi Arun,

I tried same in my PDI and it is working properly.

Check attached screenshots.

Business Rule -

find_real_file.png

find_real_file.png

 

Incident task record - 

find_real_file.png

 

Incident record after resolved.

find_real_file.png

 

See result in log

find_real_file.png

 

Thanks,

Dhananjay.

View solution in original post

19 REPLIES 19

Swapnil Soni1
Giga Guru

Hi ,

I tried the same display BR and give the condition when incident state is resolved I got the result. Check the screenshot

find_real_file.png

 

And the output is

find_real_file.png

Let me know if any help.

Thanks

 

Hi Swapnil,

Thanks for the reply. It's working for me on Display BR(Means on the form) but it will not save the value in the database it seems. Please create a report and query this incident and see the description field value. May be you can check it in the list view as well.

Regards,

Arun

Ok i try this code in after insert update business rule

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

// Add your code here
var rec = new GlideRecord('incident_task');

rec.addQuery('incident', current.sys_id);

rec.query();

if (rec.next()) {

current.description= rec.getDisplayValue('state');
current.update();

}

})(current, previous);

 

Check the sc

find_real_file.png

 

It will work for me.

Try like that and let me know if any help.

If this works please mark correct and helpful.

Thanks

Hi Swapnil,

Thank you so much.

 

Regards,

Arun

Thank you arun!!

Regard

Swapnil