How to copy Fields from Change Request to Change Task?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-17-2022 04:18 AM
Hi,
We have configured change request workflows where after closing one change task second task gets created.
I have applied business rule on change request table but it is only working on first change task. How to populate values on second change task?
Table : change_request (After ---> Update)
Condition : State changes to Implement
Script :
(function executeRule(current, previous /*null when async*/ ) {
var task_gr = new GlideRecord('change_task');
task_gr.addQuery('change_request', current.sys_id);
task_gr.query();
while (task_gr.next()) {
task_gr.planned_start_date = current.start_date;
task_gr.planned_end_date = current.end_date;
task_gr.assignment_group = current.assignment_group;
task_gr.cmdb_ci = current.cmdb_ci;
task_gr.update();
}
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-17-2022 04:33 AM
Hi,
Is the CHG getting updated while creating 2nd task?
why not use before insert BR on change_task and set the fields during insertion itself
current.planned_start_date = current.change_request.start_date;
current.planned_end_date = current.current.end_date;
current.assignment_group = current.current.assignment_group;
current.cmdb_ci = current.current.cmdb_ci;
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-17-2022 04:55 AM
Hi Ankur,
Thank you.
Yes Change will update while creating second task.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-17-2022 06:07 AM
Hi,
then in that case it might not be finding the latest change_task
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-08-2025 11:54 PM
What is the solution for this?