cancel
Showing results for 
Search instead for 
Did you mean: 

Get users from the workflow

pp20218
Champ in-the-making
Champ in-the-making
Hi,

I am running the advanced workflow automatically from a space. I have the Java script that executes after a content is added to the space. My JS code is as below.

var workflow = actions.create("start-workflow");
workflow.parameters["bpm:assignee"] = person;

Here person stands per the current user. But my requirement is I have to send to a particular user. Consider I have a Group "DEVELOPER" with 5 members in the group.

So how can I get the value of this group("DEVELOPER"); instead of "person"

Thanks
PP
15 REPLIES 15

vinaxwater
Champ in-the-making
Champ in-the-making
Hi friend,

please check hard code for view your workflow action normal with below code!

var workflow = actions.create("start-workflow");
workflow.parameters.workflowName = "jbpm$wf:review";
workflow.parameters["bpm:workflowDescription"] = document.name;

workflow.parameters["bpm:assignee"] = "admin";

var futureDate = new Date();
futureDate.setDate(futureDate.getDate() + 7);
workflow.parameters["bpm:workflowDueDate"] = futureDate;
workflow.execute(document);

if it's work fine then change with this code:

var workflow = actions.create("start-workflow");
workflow.parameters.workflowName = "jbpm$wf:review";
workflow.parameters["bpm:workflowDescription"] = document.name;
var members = people.getMembers(people.getGroup("GROUP_DEVELOPER"));
for(int i = 0; i < members.length; i++) {
logger.log(members.get(i)); //print out log in catalina.out
workflow.parameters["bpm:assignee"] = members.get(i);
var futureDate = new Date();
futureDate.setDate(futureDate.getDate() + 7);
workflow.parameters["bpm:workflowDueDate"] = futureDate;
workflow.execute(document);
}

goodluck
vinaxwater

pp20218
Champ in-the-making
Champ in-the-making
Hi Vinaxwater,

Thanks a lot for yor reply.Below is what I got.
When I tried the fir set of code as a "admin" it is working fine. Workflow assigned to admin.But when admin will do "task done" he is getting A system error happened during the operation: 07060042 Failed to signal transition '' from workflow task 'jbpm$120' error.

And the log says
caused by: org.alfresco.error.AlfrescoRuntimeException: 07060040 ReferenceError: "bpm_aproveDestination" is not defined. (AlfrescoJS#1)
   at org.alfresco.repo.jscript.RhinoScriptProcessor.executeScriptImpl(RhinoScriptProcessor.java:473)
   at org.alfresco.repo.jscript.RhinoScriptProcessor.executeString(RhinoScriptProcessor.java:250)
   … 118 more
Caused by: org.mozilla.javascript.EcmaError: ReferenceError: "bpm_aproveDestination" is not defined. (AlfrescoJS#1)
   at
………
………..

2:38,106 UserSmiley Tongueartha ERROR [ui.common.Utils] A system error happened during the operation: 07060038 Failed to execute script 'workspace://SpacesStore/0ac35339-64a4-4f39-8e63-9911cb89aa5b': identifier is a reserved word (workspace://SpacesStore/0ac35339-64a4-4f39-8e63-9911cb89aa5b#5)
org.alfresco.scripts.ScriptException: 07060038 Failed to execute script 'workspace://SpacesStore/0ac35339-64a4-4f39-8e63-9911cb89aa5b': identifier is a reserved word (workspace://SpacesStore/0ac35339-64a4-4f39-8e63-9911cb89aa5b#5)


Caused by: org.mozilla.javascript.EvaluatorException: identifier is a reserved word (workspace://SpacesStore/0ac35339-64a4-4f39-8e63-9911cb89aa5b#5)
   at org.mozilla.javascript.DefaultErrorReporter.runtimeError(DefaultErrorReporter.java:109)
   at org.mozilla.javascript.DefaultErrorReporter.error(DefaultErrorReporter.java:96)
…….
…..



Please provide me your inputs.
Thanking you in advance.
Regards
PP

vinaxwater
Champ in-the-making
Champ in-the-making
Hi friend,
Please sure your workflow work fine with start from content!

Regard
vinaxwater

pp20218
Champ in-the-making
Champ in-the-making
Hi Vinaxwater,

I had problm in the first scenario.I am not getting the first error.It got resollved for the admin scenario.
Now the second prob is still present.

I mean to say for the second set of code If I use I am still getting error.

Thanks for your help once again.

Regards
PP

vinaxwater
Champ in-the-making
Champ in-the-making
Hi friend,
You check again workfow started work fine with start with content. May be that workflow not work Smiley Very Happy

File contain define all parameter in workflow:
alfresco/projects/repository/config/alfresco/model/bpmModel.xml

File define file xml workflow:
alfresco/projects/repository/config/alfresco/bootstrap-content.xml

File define file control workflow task:
alfresco/projects/repository/config/alfresco/workflow/workflowModel.xml

Please define new workflow work fine. I don't use workflow default of alfresco so i not sure it work fine ^^
Here wiki for workflow script: http://wiki.alfresco.com/wiki/JavaScript_API_Cookbook

Regards
vinaxwater

pp20218
Champ in-the-making
Champ in-the-making
Hi,

Thanks for your reply. I checked, everything is fine.But when I use the below code I am still not able to finish my job. Again I have the same error as described above.

var workflow = actions.create("start-workflow");
workflow.parameters.workflowName = "jbpm$wf:review";
workflow.parameters["bpm:workflowDescription"] = document.name;
var members = people.getMembers(people.getGroup("GROUP_DEVELOPER"));
for(int i = 0; i < members.length; i++) {
logger.log(members.get(i)); //print out log in catalina.out
workflow.parameters["bpm:assignee"] = members.get(i);
var futureDate = new Date();
futureDate.setDate(futureDate.getDate() + 7);
workflow.parameters["bpm:workflowDueDate"] = futureDate;
workflow.execute(document);
}

Can you pls help.
Also in the Javascript API tutorial I saw a People API can you pls clarify how to use it.

Thanks again

Regards
PP