Is it possible to clone a workflow activity definition with all activity variables
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-25-2014 10:10 AM
Hello,
I am trying to clone a workflow activity definition "Create Task" with all activity variables. I am able to clone the workflow activity Definition without any activity variables using Insert. Is there a way to clone a workflow activity definition "Create Task" with all activity variables?
- Labels:
-
Service Mapping
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-28-2017 07:37 AM
The copy form section worked in Helsinki but after upgrading to Istanbul Patch 0, the variable layout is not being copied correctly. Worked with HI support and a problem was created: PRB759067 - Variable of Workflow Activity is missing in "Form Design" page in 'istanbul' & it works in Helsinki.
This is an issue when you click on Edit Variable Layout within Activity Definition. It is broken as of Istanbul Patch 2.
The workaround: (Please note, you will still have to adjust the layout afterwards but without the workaround, you will not see the fields in the Variable Layout.)
add "_wf_activity_variable" into the FormDesigner URL in between the "var__m" and the sys id that follows it.
For example:
Bad url:
Corrected url:

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-09-2017 03:52 PM
Great stuff here. Thanks for posting. I ran into an issue using this today where the UI Policies were not getting copied. It looks like the structure was changed to put them in their own tables specific to workflows and are now extended off the UI Policy and UI Policy Actions tables.
I updated the UI Action to work in Istanbul/Jakarta and have attached the updated XML for it here.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2015 08:41 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-17-2020 07:02 PM
Updated version of Jim Coyne's UI Action script.
Works with the current version of SNOW.
It will clone a workflow activity definition with all activity variables and ui policies.
//client function that runs 'onclick'
function u_copyActivityDefinitionClient()
{
if (confirm("Are you sure you want to make of copy of this Workflow Activity Definition?\n\nMake sure you have the proper Update Set selected."))
{
gsftSubmit(null, g_form.getFormElement(), "u_copy_activity_definition"); //MUST call the 'Action name' set in this UI Action
}
}
//code that runs on server
//ensure call to server-side function with no browser errors
(function()
{
if (typeof window == 'undefined') u_copyActivityDefinitionServer();
})();
function u_copyActivityDefinitionServer()
{
//server-side code goes here
var oldId = current.getValue("sys_id");
var oldName = current.getValue("name");
current.name = "Copy of " + current.getValue("name");
var newId = current.insert();
action.setRedirectURL(current);
gs.addInfoMessage("A copy of '" + oldName + "' was created");
//copy the Variables
var grVar = new GlideRecord("wf_activity_variable");
grVar.addQuery("model", oldId);
grVar.query();
while (grVar.next())
{
var oldVarTableName = grVar.getValue("name");
grVar.model = newId;
grVar.insert();
//and the choice lists
var grChoice = new GlideRecord("sys_choice");
grChoice.addQuery("name", oldVarTableName);
grChoice.addQuery("element", grVar.getValue("element"));
grChoice.query();
while (grChoice.next())
{
grChoice.name = grVar.getValue("name");
grChoice.insert();
}
}
//copy the Condition Defaults
var grDefault = new GlideRecord("wf_condition_default");
grDefault.addQuery("activity_definition", oldId);
grDefault.query();
while (grDefault.next())
{
grDefault.activity_definition = newId;
grDefault.insert();
}
//copy the Variable UI Policies
var grPolicy = new GlideRecord("wf_ui_policy");
//grPolicy.addQuery('table', 'wf_activity');
//grPolicy.addQuery('model_table', 'wf_activity_definition');
//grPolicy.addQuery('model_id', oldId);
grPolicy.addQuery('activity_definition', oldId);
grPolicy.query();
while (grPolicy.next())
{
var oldPolicy = grPolicy.getValue("sys_id");
grPolicy.activity_definition = newId;
grPolicy.insert();
var grActions = new GlideRecord('wf_ui_policy_action');
grActions.addQuery("ui_policy", oldPolicy);
grActions.addQuery('activity_definition', oldId);
grActions.query();
while (grActions.next())
{
grActions.ui_policy = grPolicy.getValue("sys_id");
grActions.activity_definition = newId;
// grActions.field = grActions.getValue("field").replace(oldId, newId);
grActions.insert();
}
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-20-2020 05:23 PM
wow, very impressive with the formatting.
I had used this to copy the 'Approval - Group' workflow activity. works a treat.