Problems accessing bpm_comment variable in transition script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-23-2007 11:21 AM
My script is below:
<transition name="Submit Response" to="approve"> <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript"> <script> var action = actions.create("create-association"); action.parameters["responseText"] = bpm_comment; action.execute(bpm_package.children[0]); </script> </action> </transition>
I suspect I am overlooking something simple, but any ideas?
- Labels:
-
Archive
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-23-2007 03:45 PM
The following is the detail on that task:
id: jbpm$5name: wf:submitAdhocTasktitle: Start Adhoc Taskdescription: Allocate task to colleaguestate: COMPLETEDpath: jbpm$2-@transitions: 1 transition: [default] , title: Task Done , desc: Task Doneproperties: 20 {http://www.alfresco.org/model/bpm/1.0}dueDate = null {http://www.alfresco.org/model/bpm/1.0}assignee = workspace://SpacesStore/8a393a59-3952-11dc-9dc7-b925da6b15f8 {http://www.alfresco.org/model/bpm/1.0}context = workspace://SpacesStore/2ccbd6af-3952-11dc-9dc7-b925da6b15f8 {http://www.alfresco.org/model/bpm/1.0}description = ad hoc desc {http://www.alfresco.org/model/bpm/1.0}workflowDescription = ad hoc desc {http://www.alfresco.org/model/content/1.0}created = 2007-07-23 14:40:37.0 {http://www.alfresco.org/model/bpm/1.0}workflowDueDate = null {http://www.alfresco.org/model/bpm/1.0}outcome = {http://www.alfresco.org/model/bpm/1.0}completionDate = 2007-07-23 14:40:37.0 {http://www.alfresco.org/model/bpm/1.0}status = Completed {http://www.alfresco.org/model/content/1.0}owner = admin {http://www.alfresco.org/model/bpm/1.0}packageActionGroup = add_package_item_actions {http://www.alfresco.org/model/bpm/1.0}priority = 2 {http://www.alfresco.org/model/bpm/1.0}startDate = null {http://www.alfresco.org/model/workflow/1.0}notifyMe = false {http://www.alfresco.org/model/bpm/1.0}percentComplete = 0 {http://www.alfresco.org/model/bpm/1.0}taskId = 5 {http://www.alfresco.org/model/bpm/1.0}package = workspace://SpacesStore/96068cdd-3954-11dc-9dc7-b925da6b15f8 {http://www.alfresco.org/model/bpm/1.0}workflowPriority = 2 {http://www.alfresco.org/model/bpm/1.0}packageItemActionGroup = start_package_item_actions

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2007 09:06 AM
In this case, bpm_comment is not transferred to the workflow context because it's actually stored on the task as a formal jbpm comment. Only named variables assigned to the task are transferred to the workflow context.
There is a way of accessing using native jbpm support:
<action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript"> <script> <expression> comment = ""; if (token.comments.size() > 0) comment = token.comments.get(0).message; </expression> <variable name="comment" access="write"/> </script> </action>
This will create a comment variable in the workflow context. Or you can just use token.comments within your script.
Workflow variable handling is still one of the areas that needs improvement, so I hope we address in future releases of Alfresco.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2007 09:48 AM
By "workflow context" is that the same as "process variables" as described in the wiki?
Also, what do you mean by named variables assigned to the task? The bpm_comment is a property on my task inherited from the parent bpm:Task. Do you mean the workflow script only has access to those properties I declare myself directly on my custom task?
Would you be able to clarify in greater detail on how task and process variables are handled then? The wiki documentation states broadly that:
"Alfresco JavaScript has access to all process variables and (if applicable) task variables, unless the <variables> element is provided, in which case, specific variables may be passed in and out of the script."
http://wiki.alfresco.com/wiki/WorkflowAdministration#Actions_.26_Scripting
Also, can you point me to some detail on the difference between the scripting syntaxes and how/if they impact what is accessible? I have not found anything that explains teh difference between using the <expression> tag versus exlcuding it within the AlfrescoScriptAction.
If I understand what you are saying, the wiki doc is not accurate?
I apologize for so many questions. How variables are handled and interact with scripting greatly impacts the usefulness of the Alfresco Workflow component so is a critical decision point when comparing ECM products for my client. Thanks again for your help!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2007 05:46 AM
By "workflow context" is that the same as "process variables" as described in the wiki?
Yes
Also, what do you mean by named variables assigned to the task? The bpm_comment is a property on my task inherited from the parent bpm:Task. Do you mean the workflow script only has access to those properties I declare myself directly on my custom task?
In jBPM, a task may have an associated set of name/value pairs (or otherwise known as variables). This allows arbitrary data to be associated with the task. However, in jBPM, a task also supports basic built-in properties such as Id, assignee, comments, priority etc. The properties in the Alfresco Task model either map to one of the built-in jBPM task properties or a named/value pair (if a built-in property is not appropriate).
At this time, only variables on the task are pushed back to workflow variables - not built-in task properties. Comment is a built-in property, therefore it's not pushed back as a workflow variable.
For custom task types that derive from bpm:Task, all of their custom properties are mapped to task variables and therefore pushed back to workflow variables and accessible in script.
So, the area where I see improvements can be made, is access to task properties directly in script. jBPM provides a 'taskInstance' variable which gives access to built-in properties and also associated name/value pairs, but the api could be simplified and made consistent with our approach to accessing properties on an Alfresco node.
Also, can you point me to some detail on the difference between the scripting syntaxes and how/if they impact what is accessible? I have not found anything that explains teh difference between using the <expression> tag versus exlcuding it within the AlfrescoScriptAction.
The expression tag alone makes no difference to what the script can achieve or has access to. It's used primarily in conjunction with the variable tag which allows explicit control over the workflow variables that are made available to the script. See the jBPM docs for more info.
If I understand what you are saying, the wiki doc is not accurate?
The wiki doc needs to provide more information and clarification. I'd like to overhaul the whole workflow administration wiki to allow people to ease into workflow step-by-step. It's a bit of chicken & egg situation - I need to find time to do that, but it's partly spent on supporting and training workflow. The good news is that we have new engineering resource to apply to workflow.
I apologize for so many questions. How variables are handled and interact with scripting greatly impacts the usefulness of the Alfresco Workflow component so is a critical decision point when comparing ECM products for my client. Thanks again for your help!
No problem - I'm sure we have a workflow component that compares to any ECM (open or proprietary) system. We're probably lacking in documentation and some ease-of-use. But, that'll be resolved.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2007 08:29 AM
Thanks again for the great work and great product!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-10-2007 03:06 PM
Thanks.
Jeff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-29-2010 02:24 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-19-2010 02:51 AM
In jBPM, a task may have an associated set of name/value pairs (or otherwise known as variables). This allows arbitrary data to be associated with the task. However, in jBPM, a task also supports basic built-in properties such as Id, assignee, comments, priority etc. The properties in the Alfresco Task model either map to one of the built-in jBPM task properties or a named/value pair (if a built-in property is not appropriate).I have a problem of a different kind, I can't update bpm:assignee with new value in Java when updating task prior to signaling it. I have whole topic on this, but no one has answered so far:
At this time, only variables on the task are pushed back to workflow variables - not built-in task properties. Comment is a built-in property, therefore it's not pushed back as a workflow variable.
For custom task types that derive from bpm:Task, all of their custom properties are mapped to task variables and therefore pushed back to workflow variables and accessible in script.
…
http://forums.alfresco.com/en/viewtopic.php?f=34&t=35005
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-27-2014 08:32 AM
How can i access the filename on which the advance workflow is trigerred inside the workflow process definition using javascript.
