
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2016 12:28 PM
Hello,
I have a request to create multiple tasks from a workflow script depending on the items assigned to a user. There is no set amount of tasks that needs to be created, could be 1, 2 or 3, depends on the assets assigned. I am having a hard time querying the items assigned to the user to be able to create a task for each one.
Basically, I am querying a table (Master) to see how many master records are assigned to the user and then create a task per record found. An Assets table is referenced form the Master table which contains the assignment group that the tasks need to be assigned to.
My goal is to query the Master table, identify how many master records are assigned to the user, and create tasks for each master record found for the user and assign it to the group in the assets table.
This is what I've been working on but this isn't working as expected, it doesn't create the tasks...
Workflow script:
var assnt_group = [];
var RequestedFor = current.variables.requested_for;
var gr = new GlideRecord('u_nerc_cip_access');
gr.addQuery('u_contact_name', RequestedFor);
gr.query();
var grps = 0;
while(gr.next()) {
assnt_group.push(gr.u_asset.u_contractor_pra_contact_group + "");
}
//Then you can create a task for each assignment group
for(var i=0; i < assnt_group.length; i++ ) {
try{
var tsk = new GlideRecord('sc_task');
tsk.initialize();
tsk.u_access_requested_for = current.variables.u_term_name;
tsk.due_date = current.due_date;
tsk.request_item = current.sys_id;
tsk.parent = current.sys_id;
//tsk.assignment_group = acc.u_asset.u_contractor_pra_contact_group;
tsk.short_description = "Enter Contractor / Vendor's Valid Background Check Date";
tsk.description = "1.Enter the contractor / vendor's valid NERC-CIP background check date. (This may require contacting the vendor to attest to a new background check if the current one is older than 6.5 years.)"+"\n";
tsk.description += "2.Close the Task.";
tsk.state = 1;
tsk.u_bg = 'true';
tsk.u_business_reason = current.variables.u_business_reason;
task.assignment_group = assnt_group[i];
task.insert();
} catch(e) {
gs.log("Exception in task creation " + e);
}
}
Any help is truly appreciated!
Thank you,
Yeny
Solved! Go to Solution.
- Labels:
-
Service Mapping

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2016 01:31 PM
You defined the object and called it 'arr', but later tried to use it as arrayUtil.
Change them all to one or other and you should be fine.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-05-2018 11:12 AM
I know this post is from a couple years ago, but I have a requirement that may be satisfied by implementing your suggestion.
We have a Catalog item used to request servers be built and deployed on the network. The users typically submit 10+ servers as part of a project and each server build has 6 steps so they want a single RITM that will capture data for multiple servers so they can track progress under 1 RITM (making it easier to see status of the server builds). We are using tables to capture the specific server information and those tables will be related lists to the RITM.
We would like to create a single catalog task for each owning group at each build step. So, for example, a user submits a build and they have 3 windows servers with Owning Group A and 2 Linux servers with Owning Group B. So, for Activity 1, there would be two catalog tasks created (one for Group A and one for Group B). Then, when Group A completed its work on the 3 windows servers and closed their catalog task, another catalog task would be created for the step in the build process. The intent is to allow groups of servers to move through the process without being held up by other groups. Does that make sense?
Is this a good use case for what you provided above (with some tweaking)