Copying data from Outage master task to child tasks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-22-2024 04:01 AM
Hi all,
A bit of background. We are using a shared project called system status v2 which allows for our users to view current outages and click a UI Action called "I'm affected too" which generates an Incident and links it to the outage.
We're having an issue for standard ITIL users being unable to trigger the copying of some fields from the outages master incident to the children ticket because of ACL restrictions that we do not want to change so instead I want to use a Business Rule on the task_outage table that copies these fields over.
When the user clicks the "I'm affected too" button it creates a new record on the task_outage table as below.
I want the business rule to go into the Outage record below, into the task_number reference field..
And take the values from the business_service (reference field), category, subcategory, and assignment_group (reference field) and insert them into the Incident found in the task field shown in the first screenshot.
I tried a script with some table queries in but found it was running indefinitely and not working. So I figured could it be as simple as doing a bit of dot walking? So I have the script below which also, is not working.
(function executeRule(current, previous /*null when async*/) {
current.task.assignment_group = current.outage.task_number.assignment_group;
current.task.business_service = current.outage.task_number.business_service;
current.task.category = current.outage.task_number.category;
current.task.subcategory = current.outage.task_number.subcategory;
})(current, previous);
Any assistance would be greatly appreciated!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-22-2024 05:26 AM
Hello @LRhodes
Use this script-
(function executeRule(current, previous /*null when async*/) {
var grTask = new GlideRecord('table name of task where you want to update');
grTask.addQuery('sys_id',current.task);
grTask.query();
if(gr.next()){
grTask.assignment_group = current.outage.task_number.assignment_group;
grTask.business_service = current.outage.task_number.business_service;
grTask.category = current.outage.task_number.category;
grTask.subcategory = current.outage.task_number.subcategory;
grTask.update();
}
})(current, previous);
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.