Is it possible to duplicate a Catalog Task record including it's variables?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-30-2012 02:36 PM
We have a Service Catalog item that is using workflow to create task records and the variables that should appear on the task form. A task that has been created by the workflow may need to be worked on by more than one group therefore I need a way to duplicate that task so that it can be assigned to multiple groups at the same time.
I set up a UI Action to duplicate the task so that it can be sent to more than one assignment group to work on. It duplicates the task however it does not show the variables that display on the original task.
I also need to have the workflow wait for the duplicated task or tasks to be complete before the workflow marks the request as complete. I did create a business rule and placed a wait condition before the end of my workflow as described in Wiki article http://wiki.servicenow.com/index.php?title=Condition_Activities. This doesn't stop the workflow from completing the request yet the duplicate task shows in the related list for the request.
I have a couple of issues I am trying to solve.
1. Would anyone know how I can get the variables that are on the original task record to copy to the new task record?
2. Would anyone know how I can get the workflow to wait for the duplicated tasks to be complete before completing the request?
3. Is there a better way to handle duplicating a Service Catalog Task?
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-07-2012 10:38 AM
Well after I responded I did a little more testing and discovered that when I set these variables to global they do copy forward however the system now shows all variables on all tasks regarless of what fields I am stating to show when the task is created by the workflow. I really don't want that. I want only the fields I defined in the workflow when creating the task. Is there a way to copy variables that are listed in the task that I copy without having all display on the task?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-17-2012 02:08 PM
So, I know this is an old post, but I didn't see any other answers anywhere on how to do this, so here 's mine.
Here's what copies the variables on my catalog tasks (this is all from a UI Action on the Task table). To copy the rest of the task, I manually enter the field names to copy one by one in my script; there's probably a faster way to do it, but I didn't.
var gr = new GlideRecord('sc_task');
gr.initialize();
// set other fields as desired
...
gr.insert(); // I think this is necessary before the next steps, but I didn't test it the other way
if(current.sys_class_name == 'sc_task'){
var cat_var_src = new GlideRecord('sc_item_variables_task');
var cat_var_dest = new GlideRecord('sc_item_variables_task');
cat_var_src.addQuery('task', current.sys_id);
cat_var_src.query();
while(cat_var_src.next()){
cat_var_dest.initialize()
cat_var_dest.task = gr.sys_id;
cat_var_dest.variable = cat_var_src.variable;
cat_var_dest.insert();
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-19-2012 10:55 AM
Thank you. I will give this a try.