cancel
Showing results for 
Search instead for 
Did you mean: 

set the initiator for a workflow via script?

targa2000
Champ in-the-making
Champ in-the-making
how can I set or can I set the initiator for a workflow in a script?

var workflow = actions.create("start-workflow");
workflow.parameters.workflowName = "jbpm$wf:adhoc";
workflow.parameters["bpm:workflowDescription"] = "The attached document has been uploaded to Alfresco. Please review within 3 days.";
workflow.parameters["bpm:assignee"] = "admin";
var futureDate = new Date();
futureDate.setDate(futureDate.getDate() + 3);
workflow.parameters["bpm:workflowDueDate"] = futureDate;
workflow.execute(document);

using the above as a basis, is there a way to assign the initiator?
4 REPLIES 4

hsohaib
Champ on-the-rise
Champ on-the-rise
Have you tried this one ?


var workflow = actions.create("start-workflow");
workflow.parameters.workflowName = "jbpm$wf:adhoc";
workflow.parameters["bpm:workflowDescription"] = "The attached document has been uploaded to Alfresco. Please review within 3 days.";
workflow.parameters["bpm:assignee"] = people.getPerson("admin");
workflow.parameters["initiator"] = people.getPerson("someone");
var futureDate = new Date();
futureDate.setDate(futureDate.getDate() + 3);
workflow.parameters["bpm:workflowDueDate"] = futureDate;
workflow.execute(document);

Hope it works

alarocca
Champ in-the-making
Champ in-the-making
I have tried this and in fact the start task seems to be started by the user specified rather the current user. Unfortunately the end task, even if in the initiator swimlane, is assigned to the current user rather then the one specified. Do you have solved this issue?

Have you tried this one ?


var workflow = actions.create("start-workflow");
workflow.parameters.workflowName = "jbpm$wf:adhoc";
workflow.parameters["bpm:workflowDescription"] = "The attached document has been uploaded to Alfresco. Please review within 3 days.";
workflow.parameters["bpm:assignee"] = people.getPerson("admin");
workflow.parameters["initiator"] = people.getPerson("someone");
var futureDate = new Date();
futureDate.setDate(futureDate.getDate() + 3);
workflow.parameters["bpm:workflowDueDate"] = futureDate;
workflow.execute(document);

Hope it works

jperilla
Champ in-the-making
Champ in-the-making
Did you solve this?

I need to set the initiator or the owner of the workflow to a group, so that people in that group can see the workflows in their "Workflows I've started" list.

For restricting workflow to particular group you need to customize the start-workflow.get.js.

This is the file which is responsible for retrieving the workflow definitions.In this file you need call repository webscript which will identify whether the current logged in user is in particular group or not and based on the result show/hide the workflow.