Is it possible to duplicate a Catalog Task record including it's variables?

abrahams
Kilo Sage

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?

7 REPLIES 7

darcieopferman
Kilo Explorer

I am in the exact same situation and found it interesting that only one of my variables was copied to the new catalog task.

My UI Action is a basic Insert and Stay that I renamed "Copy Task". I read a lot about about creating a UI Action with scripting, but do not have much scripting experince so couldn't figure out how to customize it for the catalog tasks. If you would share how you copied your catalog task I would appreciate it.

And I look forward to someone in the community helping figure out why our variables are not copying over. Thanks!!


darcieopferman
Kilo Explorer

As I entered my last post, I thought it might be tied to the variables, not the task form ui action. Sure enough, the one variable that would copy for me was marked as Global and all the others were not.

I made all of my variables Global and now they are copying as I wanted. I hope that helps!


abrahams
Kilo Sage

Thank you so very much ... making the variables global worked great. Below is a UI Action that I put together. I basically copied what was out there and added just a little code because I wanted a different number and I also wanted to know which task was copied.

Name: Duplicate and Save
Table: Catalog Task [sc_task]
Script:
doDuplicateAndSave();
function doDuplicateAndSave() {
var saveMe = current;

//set new defaults
current.state = true;
current.short_description += ' - Duplicated Task from ' + current.number;

if (typeof current.number != 'undefined' && current.number) {
current.number = ""; // generate a new number
}
current.insert();
// action.setRedirectURL(saveMe);
}


abrahams
Kilo Sage

Would anyone know how to get the workflow to recognize that this duplicated task exists and shouldn't complete the request until the duplicated task is complete?