How to find current workflow user? [SOLVED]
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-13-2007 07:09 AM
Hi All,
Again help in advance.
Within my process definition I have the following task. In it I'm trying to find the current user who kicks of the "Send to Artist" transition.
I've tried the above but I get null for bpm_assignee. I've deliberately ignored initiator although I get a value for this the wiki states this is "the person who initiated the workflow", and I don't need that information.
My question is: Which variable do I need to access to find the current user?
Jim
Again help in advance.
Within my process definition I have the following task. In it I'm trying to find the current user who kicks of the "Send to Artist" transition.
<task-node name="Waiting for Artist"> <task name="wf:waitingForArtistTask" swimlane="artistsPool" /> <transition name="Send to Artist" to="Create"> <script> <variable name="wf_reader" access="write" /> <variable name="bpm_assignee" access="read" /> <expression> wf_reader = "New reader = " + bpm_assignee; </expression> </script> </transition></task-node>
I've tried the above but I get null for bpm_assignee. I've deliberately ignored initiator although I get a value for this the wiki states this is "the person who initiated the workflow", and I don't need that information.
My question is: Which variable do I need to access to find the current user?
Jim
Labels:
- Labels:
-
Archive
4 REPLIES 4

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-13-2007 08:29 AM
YOu could use the "variable" person to access the current user performing an action!
For instance:
In your case you have probably add also
Good luck. Rob
For instance:
person.properties.userNamewould return the user name of the current user.
In your case you have probably add also
<variable name="person" access="read"/>
to your script.Good luck. Rob
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-13-2007 08:43 AM
Hi rob,
I've tried the following:
But all I get is a null pointer exception. Looking more closely person is null. Do I need to add this to my aspect? Or how do I inherit it?
Jim
I've tried the following:
<task-node name="Waiting for Artist"> <task name="wf:waitingForArtistTask" swimlane="artistsPool" /> <transition name="Send to Artist" to="Create"> <script> <variable name="wf_reader" access="read,write" /> <variable name="person" access="read" /> <expression> wf_reader = "new reader = " + person.properties.userName; </expression> </script> </transition></task-node>
But all I get is a null pointer exception. Looking more closely person is null. Do I need to add this to my aspect? Or how do I inherit it?
Jim

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-13-2007 08:53 AM
Hi Jim,
I think the problem is that you are using "Java" and not "JavaScript"
Here is an example of some code I use:
As you can see I did not use the
Success,
Regards, Rob
I think the problem is that you are using "Java" and not "JavaScript"
Here is an example of some code I use:
<transition name="Continue" to="createCcr"> <condition>#{!qcp_wfIssueExist}</condition> <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript"> <script> var logDateTime = new Date(); var ccrLogFile = companyhome.childByNamePath("CCR repository/Log files/" + qcp_wfCcrNr + ".log"); if (ccrLogFile != null) { var logLine = logDateTime.getFullYear() + ";" + utils.pad(logDateTime.getMonth()+1,2) + ";" + utils.pad(logDateTime.getDate(),2); logLine += ";" + utils.pad(logDateTime.getHours(),2) + ";" + utils.pad(logDateTime.getMinutes(),2) + ";" + utils.pad(logDateTime.getSeconds(),2); logLine += ";" + utils.pad(logDateTime.getTime(),16); logLine += ";" + qcp_wfCcrNr; logLine += ";" + person.properties.userName + ";" + "" + ";" + qcp_wfCycleNr; logLine += ";" + "Issue number checked and found unique"; logLine += ";" + bpm_package.children[0].properties["qcp:previousWorkflowStatus"]; logLine += ";" + bpm_package.children[0].properties["qcp:currentWorkflowStatus"]; ccrLogFile.content += logLine + "\r\n"; } bpm_package.children[0].properties["qcp:previousWorkflowStatus"] = "qcp:mayCreateCcr"; bpm_package.children[0].save(); if (bpm_package.children.length > 1) for (var i = 1; i < bpm_package.children.length; i++) if (bpm_package.children[i].parent.properties.name != bpm_package.children[0].parent.properties.name) { var newCopy = bpm_package.children[i].copy(bpm_package.children[0].parent); bpm_package.removeNode(bpm_package.children[i]); bpm_package.addNode(newCopy); } </script> </action> </transition>
So you might try to add <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">and
</action>around your script.
As you can see I did not use the
<variableand
<expressiontags but that would not be the problem I guess.
Success,
Regards, Rob
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-13-2007 09:47 AM
SOLVED: MANY MANY thanks rob, I just needed the right combination. The following works. It has a bit of a red herring because the various error messages did not relate to their being a problem with the tagging….
<task-node name="Waiting for Artist"> <task name="wf:waitingForArtistTask" swimlane="artistsPool" /> <transition name="Send to Artist" to="Create"> <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript"> <script> <variable name="wf_reader" access="read,write" /> <expression> wf_reader = person.properties.userName; </expression> </script> </action> </transition></task-node>
