- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
required help @Vasantharajan N @Ankur Bawiskar @Voona Rohila @WillieW @RaghavSh @Matthew_13 @SumanthDosapati
As I need to automate the standard change request creation every 2nd Friday of the month for the change templates that I have with me.
Along with that change tasks also need to create and those change tasks need to auto assign to assignment groups that I have mentioned
Short Description: [assignment_group] Microsoft Patching
Description: New Microsoft patches installed
Change Template:
1. Monthly Microsoft Patching
2. Monthly PMPC Patching
Assignment Groups:
- Supply Chain Engineering
- Corporate Engineering
- Digital Engineering
Tried below Schedule Job:
with below script Change request and change task is getting created but the fields in the change request are not getting populated with the change template field values and it should execute on 2nd Thursday of every month so replaced with 4.
(function() {
var templateName = 'sys ID of the Template'; // Replace with your template name
var change = new GlideRecord('change_request');
change.initialize();
change.type = 'standard'; // Ensure the change type is standard
// Apply the template
if (change.applyTemplate(templateName) == 0) {
gs.info('Template applied successfully to change request');
} else {
gs.info('Failed to apply template');
}
// Insert the change request
var changeSysId = change.insert();
gs.info('Standard change request created: ' + changeSysId);
// logic to create change tasks
var rec = new GlideRecord('change_task');
rec.initialize();
rec.change_request = changeSysId;
rec.short_description = 'Your Testing';
rec.description = 'Confirm business application functions as it should with new Microsoft patches installed.';
rec.assignment_group.setDisplayValue('Supply Chain Engineering');
rec.insert();
})();Error when checked in Background script:
*** Script: Failed to apply template #### Compiler Stats #### Compiles: 1, time: 924ms Total classes: 8, bytecode length: 0 Total loaders created: 8, unloaded: 8, existing: 0 Interpreted compiles: 18,800, time: 8,961ms Cache name: "syscache_expression", max: 7,447, size: 7,678, seeks: 194,386,910, hits: 97,178,102, misses: 97,208,808, flushed: 0, row evictions: 0, single key evictions: 7,460, puts: 0, reclaims: 0, time from last reclaim to recreation total ms: 0, average time from last reclaim to recreation ms: 0 *** Script [TaskSLAFlow]: 2025-12-15 06:47:37.852 start: failed to start Flow "Default SLA flow" for Task SLA bfad3eca933db210fc57ff584dba1008: com.snc.process_flow.exception.ProcessAutomationException: Failed to find complex object schema *** Script [TaskSLAFlow]: 2025-12-15 06:47:37.883 start: failed to start Flow "Default SLA flow" for Task SLA 37ad3eca933db210fc57ff584dba100c: com.snc.process_flow.exception.ProcessAutomationException: Failed to find complex object schema Slow business rule 'Run SLAs' on change_request:<span class = "session-log-bold-text"> CHG0047407</span>, time was: 0:00:00.123 notification.provider: For Synchronous Providers: Loaded 0 recipients and 0 destinations and delivered to 0 destinations in 2ms TriggerEngine:runEngine took 0.006ms to process for 'insert' operation on the record change_request[ffadba0e93f5b210fc57ff584dba101c] *** Script: Standard change request created: ffadba0e93f5b210fc57ff584dba101c
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
As per your logs, it says change request is created with sys_id
ffadba0e93f5b210fc57ff584dba101c
Check your change_request table with sys_id = "ffadba0e93f5b210fc57ff584dba101c"
Regards,
Sumanth
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago - last edited 3 weeks ago
But it's creating Change Request Type: Normal not Standard
And in the Error log it's showing as when I run the script in the background script.
Failed to apply template
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 weeks ago
Try below changes :
- In the starting of your script, change the below from
var templateName = 'sys ID of the Template';
TOvar templateName = 'Name of the Template'; - Change the below from
// Apply the template if (change.applyTemplate(templateName) == 0) { gs.info('Template applied successfully to change request'); } else { gs.info('Failed to apply template'); }TOchange.std_change_producer_version = 'sys_id'; // Sys ID of the Standard Change Templates version change.applyTemplate('templateName');
