- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2020 09:15 PM
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
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-23-2020 01:56 AM
Hi Arun,
I tried same in my PDI and it is working properly.
Check attached screenshots.
Business Rule -
Incident task record -
Incident record after resolved.
See result in log
Thanks,
Dhananjay.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2020 09:28 PM
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');
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2020 11:14 PM
Hi Dhananjay,
I've tried the same, but no luck.
Regards,
Arun

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2020 11:47 PM
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
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-23-2020 01:28 AM
Hi Dhananjay,
After making the changes there is no logs i found. This is something strange:(
Regards,
Arun

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-23-2020 01:56 AM