cancel
Showing results for 
Search instead for 
Did you mean: 

Task assignee variable

beber7
Champ in-the-making
Champ in-the-making
Hello guys,

I'm writting you after spending a day looking for answer all over the web for something that might be really simple to you.

I've created a workflow in Activit Explorer ( similar to a adhoc wf than I will make more complex later on ).
In this worflow, I just want to assign a task to a user ( yes that's it ) and deploy it to alfresco.

Start -> user task -> end

Base on what I've seen so far, I wanted to use the following argument on the task assignee parameter : ${bpm_assignee.properties.userName}

I figured the activiti engine does not know about bpm and get an error " Unknow property used … " when I drop a file in a specific folder.

Note : I use Javascript code, that is trigger by a rule "On document created or move into folder" to instanciate the workflow.

Here is the code, very simple :


function createAdvancedWorkflow() {
   var workflow = actions.create("start-workflow");
   workflow.parameters.workflowName = "activiti$workflowbased";
   workflow.parameters["bpm:workflowDescription"] = "The attached document has been uploaded to Alfresco. Please review within 3 days.";
   workflow.parameters["bpm:assignee"] = "admin"; // TODO: not hard coded, this is testing

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

function main() {
       logger.warn("Test warn OK");
       createAdvancedWorkflow();
}

So the question is :
- In activity explorer when editing my task what variable can I use to be able to assign a user to the task from the JS code ?
( What should I use instead of ${bpm_assignee.properties.userName} to make this work :  workflow.parameters["bpm:assignee"] = "admin; )

If anyone can be the light in my shadow it would be much appreciated.
Thank you for your time Smiley Happy


4 REPLIES 4

jbarrez
Star Contributor
Star Contributor
Activiti Explorer uses a different process engine configuration than the one in Alfresoc.
You'd need to mimic the process engine config exactly on both side to make it work. For example the bpm.xx variables are added by ParseHandlers that are specific to Alfresco and which do not exist in the vanilla engine config.

martin_grofcik
Confirmed Champ
Confirmed Champ
Hi,

- In activity explorer when editing my task what variable can I use to be able to assign a user to the task from the JS code ?
see:
http://activiti.org/userguide/index.html#bpmnScriptTaskVariables

For your case I would use spring bean which can access properties.

Regards
Martin

beber7
Champ in-the-making
Champ in-the-making
Hey thank you both of you for your answers.

@Jbarrez : That makes sense, but how can I do such a thing ?
@Martin : Thanks for the link. My JS script is an external file that only instanciate the workflow and assign a user to a userTask. It's not a script in a ScriptTask. The bean sound like a plan, I'm really new with this notion though.

Can we go a little more in details here, I'm going to try to be more specific since I'm a little lost.
I think what I need to understand is the correlation between :


activiti:assignee="${bpm_assignee.properties.userName}"
(in xxx.bpmn20.xml)

and


workflow.parameters["bpm:assignee"] = "admin";
(in xxx.js - triggered by an alfresco rule)

Questions :
- What is this ${} thing ? I believe it's to define a variable. If yes, then shouldn't we have a list of what variable is accessible ?
- How does the variable match between the XML and the JS ( from ${bpm_assignee.properties.userName} to workflow.parameters["bpm:assignee"]  ? I believe the bean is the connection between the two.
- I understand there is different engines here.. but I'm a little lost on how everything interact, I've the general idea but if someone can explain me what engine belong where, and what is accessible or not in this situation, It will help a lot.
( I understand that using "activiti$…" as workflow engine prevents me from using "bpm:<variable>" for wf parameters. I don't know how to solve this ).

At the moment, I believe that if I can generate the right bean, it will work with the actual XML and JS code… but I'm not sure at all.

PS: I've installed eclipse all the plugins and stuff when I was doing tutorials such as this one http://ecmarchitect.com/images/articles/alfresco-workflow/advanced-workflow-article-2ed.pdf
So I'm ready to go for any advice or things to do, or if I need to create a war.

Right now I decided to deploy my workflow using alfresco/activiti-admin, so I'm only asked to give the bpmn20.xml and nothing else and that might be wrong if I need to deploy beans.

Thank you again, sorry with all this questions, please tell me if some of them does not makes real sens,  I will try to be more specific.

Sincerly,
Bert

jbarrez
Star Contributor
Star Contributor
> What is this ${} thing

It's an expression. It had access to your variables. And beans, if running in spring.

> How does the variable match between the XML and the JS

That seems to be an alfresco specific thing, sorry, can't help with that.

> I understand there is different engines here.. but I'm a little lost on how everything interact,

Activiti is a engine, basically you instantiate it in Java as a regular object. However, in Alfresco, the engine is instantiated using a very different configuration, adding all kinds of extras, which isn't there in the vanilla setup.

The beans here, are Alfresco Spring beans. You can indeed reference them in those expressions, like ${someBean.someMethode(someVariable)}.

However, as I stated above, making sure the config matches between Alfresco and Activiti is not an easy task!