<webscript>
<shortname>Create Workflow Instance</shortname>
<description>
Creates a workflow instance and returns a instance identification of the new workflow.
</description>
<url>/workflow-instance-create?definition={definition}&description={description}&assign={assign}&=fileNodeId{fileNodeId?}
</url>
<args>
<arg>
<shortname>definition</shortname>
<description>the work flow definition name</description>
</arg>
<arg>
<shortname>description</shortname>
<description>the description for the new workflow</description>
</arg>
<arg>
<shortname>assign</shortname>
<description>the person uid to assign the first task</description>
</arg>
<arg>
<shortname>fileNodeId</shortname>
<description>the file node id that we want to attach to the workflow</description>
</arg>
</args>
<format default="json">extension</format>
<authentication>user</authentication>
</webscript>
//Arguments values
var definition = args.definition;
var description = args.description;
var assignee = args.assign;
var FileNodeId = args.fileNodeId
var registrationWorkflowDefinition = workflow.getDefinitionByName(definition);
//Parameters
var parameters = new Object();
parameters["bpm:workflowDescription"] = description;
parameters["bpm:assignee"] =[people.getPerson(assignee)];
//Attached File
if (FileNodeId!= null)
{
var nodeId = FileNodeId;
var theDocument = search.findNode("workspace://SpacesStore/" + nodeId);
var workflowPackage = workflow.createPackage();
workflowPackage.addNode(theDocument);
}
else
{
var workflowPackage = workflow.createPackage();
}
//Creating the workflow
//Note the order of the arguments in startWorkflow method are in inverse order than documentation
var registrationWorkflowStart = registrationWorkflowDefinition.startWorkflow(workflowPackage,parameters);
//Values to return
model.workflowInstance = registrationWorkflowStart.instance;
model.workflowInstanceID = registrationWorkflowStart.id;
{
"id": "${workflowInstance.id}"
}
Content from pre 2016 and from language groups that have been closed.
Content is read-only.
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.