cancel
Showing results for 
Search instead for 
Did you mean: 

Scripting a start-workflow

blackout
Champ in-the-making
Champ in-the-making
Hi,

I'm posting to know if there's a way to browse the users (and not only those) with the API in order to start a workflow through a script.
To be more clear, let's take a look at the example code found in the wiki:
var workflow = actions.create("start-workflow");
workflow.parameters.workflowName = "jbpm$wf:review";
workflow.parameters["bpm:workflowDescription"] = document.name;
workflow.parameters["bpm:assignee"] = person;
var futureDate = new Date();
futureDate.setDate(futureDate.getDate() + 7);
workflow.parameters["bpm:workflowDueDate"] = futureDate;
workflow.execute(document);
What I'd like to do is to change the line
workflow.parameters["bpm:assignee"] = person;
so that I can reassign the review step to another user (or group of users) automatically.

If I understand correctly, it is possible with the Enterprise edition with the API "Node getPerson(string username)"; is there anything similar in the standart edition?

Thanks in advance for your help!
6 REPLIES 6

davidc
Star Contributor
Star Contributor
Node getPerson(string username)

The above javascript function is now available in HEAD.

blackout
Champ in-the-making
Champ in-the-making
Perfect! I'll take it right the way.
Thanks again

red15
Champ in-the-making
Champ in-the-making
Is it also possible to do this ?


workflow.parameters["bpm:assignee"] = getPerson("mike");
workflow.parameters["bpm:dispatcher"] = getPerson("john");
workflow.parameters["bpm:finisher"] = getPerson("david");

So in other words provide custom variables into the bpm processdefinition.

Provided of course if you have have assigned bpm_dispatcher and bpm_finisher to a swimlane.

Also I would like to know if you can change those parameters from inside the workflow later on. (As to reassign to different people)

blackout
Champ in-the-making
Champ in-the-making
I'm reading now new pages about the 2.0 version of Alfresco on the wiki, it has much richer JavaScript API to manage system users, check here http://wiki.alfresco.com/wiki/JavaScript_API#People_API and http://wiki.alfresco.com/wiki/WorkflowAdministration#Task_assignment .

Anyway, does the pages update mean that those APIs are disposable on SVN?

davidc
Star Contributor
Star Contributor
red15:

Is it also possible to do this ?

Code:

workflow.parameters["bpm:assignee"] = getPerson("mike");
workflow.parameters["bpm:dispatcher"] = getPerson("john");
workflow.parameters["bpm:finisher"] = getPerson("david");


So in other words provide custom variables into the bpm processdefinition.

Provided of course if you have have assigned bpm_dispatcher and bpm_finisher to a swimlane.

Also I would like to know if you can change those parameters from inside the workflow later on. (As to reassign to different people)

Yes, it is.

You can change the values in Task Dialogs, as long as the associated task definition includes the properties (and you've configured the task dialog UI).  You may want to use an aspect to model your assignees, then it's possible to associate it with many task definitions.

You can also make changes via script in the process definition.  So, you could do something like (it needs to be tested, the use of <variable> tags within the script may be required)…

         
<action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
           <script>
              bpm_dispatcher = people.get("fred");
           </script>
</action>

davidc
Star Contributor
Star Contributor
Blackout:

Anyway, does the pages update mean that those APIs are disposable on SVN?

They are, but the implementation is under development - so you may find issues.