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

Dhananjay Pawar
Kilo Sage

Hi,

Correct me if I am wrong.

You want to copy state of incident task when incident is closed if yes then create after update BR on incident table and add condition state changes to resolved

 

in script section

 

var rec = new GlideRecord('incident_task');

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

rec.query();

if (rec.next()) {

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

}

Hi Dhananjay,

I've tried the same, but no luck.

 

Regards,

Arun

Hi,

May I know what error you are getting?

Try below code and let me know what you are getting in logs.

var rec = new GlideRecord('incident_task');

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

rec.query();

if (rec.next()) {

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

gs.log("changed value = "+current.u_category_on_open); // navigate to system log and check what you are getting

}

Hi Dhananjay,

After making the changes there is no logs i found. This is something strange:(

 

Regards,

Arun

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.