- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-11-2019 11:16 AM
I am using a RITM workflow to create a change request. The run script to create the standard change is working and the template is applied. What isn't working is that the change template isn't creating the related change tasks. Does anyone know how to get the tasks created and applied? Here is the script that is working to create the change.
var chg = new GlideRecord('change_request');
chg.initialize();
chg.type = 'standard';
chg.applyTemplate('template_name');
chg.insert();
Thank you!
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-12-2019 05:51 AM
We were able to figure this out. All we needed was one more line, so the solution looks like this:
var chg = new GlideRecord('change_request');
chg.initialize();
chg.type = 'standard';
chg.std_change_producer_version = 'sys_id'; // Sys ID of the Standard Change Templates version
chg.applyTemplate('template_name');
chg.insert();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-11-2019 03:00 PM
Greetings, snewton!
Here is an example of how we do it in our organization!
var chg = new GlideRecord('change_request');
chg.initialize();
chg.type = 'standard';
chg.std_change_producer_version = 'bf2655bddb0109103a65f36f299619f1'; // producer version sysId
chg.applyTemplate("std chg template name"); // template name
GlideSysAttachment.copy("std_change_record_producer", "3312d1b9db0100203a65f36f29961905", chg.getTableName(), chg.getUniqueValue());
chg.insert();
When you apply a template, it is only applying the fields of said template. You also need to copy the attachments/catalog tasks to the change using the GlideSysAttachment.copy method. This can be found in the 'script' section of the `std_change_record_producer` table. The contexts will be different, but it gives a good idea of how this is being done.
Take a look at this page to further understand.
Cheers!
-W
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-12-2019 05:51 AM
We were able to figure this out. All we needed was one more line, so the solution looks like this:
var chg = new GlideRecord('change_request');
chg.initialize();
chg.type = 'standard';
chg.std_change_producer_version = 'sys_id'; // Sys ID of the Standard Change Templates version
chg.applyTemplate('template_name');
chg.insert();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2022 12:18 PM
Hi,
I have the same script that was working fine but after we modified the template and changed the assignment group in template but tickets are still was getting assigned to previous version template assignment group in system.
What could be the issue for that?
Thanks,
Chaitanya