How to create sequential task in std_change_proposal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-26-2023 11:11 PM
Hi Team ,
How we can create sequential change task in std_change_proposal ,Right now order of Task is different still all tasks created at the same time.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2025 12:27 PM
I think I am a little closer but I am not the best coder to adjust this script to grab the task in order:
There is a business rule on Change Request table called: Create Standard Change Tasks.
This BR calls the StdChangeUtils script include which is joined to the Script include StdChangeUtilsSNC. Within
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2025 10:32 AM
I think this is close thanks to AI but not sure how to implement - do you need to copy all of the StdChangeUtilsSNC script to StdChangeUtils script to get it to operate both? not sure how to extend just these few lines 511-536:
createChangeTasks: function(changeGr) {
if (!changeGr || changeGr.std_change_producer_version.nil())
return;
var versionGr = new GlideRecord(this.TABLE_NAME_VERSION);
if (!versionGr.get(changeGr.getValue('std_change_producer_version')))
return;
var proposalGr = new GlideRecord(this.TABLE_NAME_PROPOSAL);
if (!proposalGr.get(versionGr.getValue('std_change_proposal')))
return;
var relatedTaskTemplateGr = new GlideRecord(this.TABLE_NAME_RELATED_TASK);
relatedTaskTemplateGr.addQuery('std_change_proposal', proposalGr.getUniqueValue());
relatedTaskTemplateGr.orderBy('order');
relatedTaskTemplateGr.query();
var changeTaskGr = new GlideRecord(this.TABLE_NAME_CHANGE_TASK);
var previousTaskSysId = null;
var currentOrder = null;
var tasksToCreate = [];
while (relatedTaskTemplateGr.next()) {
if (currentOrder !== relatedTaskTemplateGr.getValue('order')) {
if (tasksToCreate.length > 0) {
createTasks(tasksToCreate, changeGr, previousTaskSysId);
tasksToCreate = [];
}
currentOrder = relatedTaskTemplateGr.getValue('order');
}
tasksToCreate.push(relatedTaskTemplateGr.getValue('template'));
}
if (tasksToCreate.length > 0) {
createTasks(tasksToCreate, changeGr, previousTaskSysId);
}
function createTasks(taskTemplates, changeGr, previousTaskSysId) {
if (previousTaskSysId) {
var previousTaskGr = new GlideRecord(this.TABLE_NAME_CHANGE_TASK);
previousTaskGr.get(previousTaskSysId);
while (previousTaskGr.state != '3') { //3 = State closed
previousTaskGr.refresh();
gs.sleep(30000); // Wait for 30 second before checking again
}
}
taskTemplates.forEach(function(template) {
changeTaskGr.initialize();
changeTaskGr.setValue(this.TABLE_NAME_CHANGE, changeGr.getUniqueValue());
changeTaskGr.applyEncodedQuery(template);
previousTaskSysId = changeTaskGr.insert();
}.bind(this));
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2025 11:39 AM
Put the function where indicated by the comments in the StdChangeUtils script include: