trouble accessing document properties in workflow script
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-16-2008 01:52 PM
Hi to everyone, while trying to access (alfresco labs 3.0.0 (c 1342)) a document property from an advanced workflow script, I run against a number of issues, such as a NullPointerException. For instance, this syntax will not work (nor I could find the logger variable) :
By reading alfresco sources, I managed to find out a working syntax, but rather awkward imho with respect to the wiki :
As I said, this code will work, but should be much easier, shouldn't it?
Deatils over the exception with the first snippet (caused by bpm_package not having a context, not having a scope etc.) :
Am I doing something wrong here? Would you like me to provide more detail about this, or submit a Jira Issue?
Thanks in advance,
Luca
<task-node name="adhoc"> <task name="wf:adhocTask" swimlane="assignee"> <event type="task-create"> <script> System.out.println("property : " + bpm_package.children[0].properties.myproperty); </script> </event> </task> <transition name="" to="completed" /> </task-node>
By reading alfresco sources, I managed to find out a working syntax, but rather awkward imho with respect to the wiki :
<task-node name="adhoc"> <task name="wf:adhocTask" swimlane="assignee"> <event type="task-create"> <script> org.mozilla.javascript.Context.enter(); org.mozilla.javascript.Scriptable scope = org.mozilla.javascript.Context.getCurrentContext().initStandardObjects(); bpm_package.setScope(scope); System.out.println("property before : " + bpm_package.children.get(0, null).properties.get("{http://acme.com/model/customer1/content/1.0}myproperty")); bpm_package.children.get(0, null).properties.put("{http://acme.com/model/customer1/content/1.0}myproperty','NewValue"); bpm_package.children.get(0, null).save(); System.out.println("property after : " + bpm_package.children.get(0, null).properties.get("{http://acme.com/model/customer1/content/1.0}myproperty")); </script> </event> </task> <transition name="" to="completed" /> </task-node>
As I said, this code will work, but should be much easier, shouldn't it?
Deatils over the exception with the first snippet (caused by bpm_package not having a context, not having a scope etc.) :
19:36:37,980 WARN [graph.action.Script] exception during evaluation of script expressionSourced file: inline evaluation of: `` System.out.println("property before : " + bpm_package.children[0]. . . . '' : Property accessor threw exception: java.lang.NullPointerException : at Line: 2 : in file: inline evaluation of: `` System.out.println("property before : " + bpm_package.children[0]. . . . '' : bpm_package .children at bsh.UtilEvalError.toEvalError(Unknown Source) at bsh.UtilEvalError.toEvalError(Unknown Source) at bsh.BSHAmbiguousName.toObject(Unknown Source) at bsh.BSHAmbiguousName.toObject(Unknown Source) at bsh.BSHPrimarySuffix.doSuffix(Unknown Source) at bsh.BSHPrimaryExpression.eval(Unknown Source) at bsh.BSHPrimaryExpression.eval(Unknown Source) at bsh.BSHBinaryExpression.eval(Unknown Source) at bsh.BSHArguments.getArguments(Unknown Source) at bsh.BSHMethodInvocation.eval(Unknown Source) at bsh.BSHPrimaryExpression.eval(Unknown Source) at bsh.BSHPrimaryExpression.eval(Unknown Source) at bsh.Interpreter.eval(Unknown Source) at bsh.Interpreter.eval(Unknown Source) at bsh.Interpreter.eval(Unknown Source) at org.jbpm.graph.action.Script.eval(Script.java:130) at org.jbpm.graph.action.Script.eval(Script.java:73) at org.jbpm.graph.action.Script.execute(Script.java:62) at org.jbpm.graph.def.GraphElement.executeAction(GraphElement.java:264) at org.jbpm.graph.def.GraphElement.executeActions(GraphElement.java:220) at org.jbpm.graph.def.GraphElement.fireAndPropagateEvent(GraphElement.java:190) at org.jbpm.graph.def.GraphElement.fireEvent(GraphElement.java:174) at org.jbpm.taskmgmt.exe.TaskInstance.create(TaskInstance.java:170) at org.alfresco.repo.workflow.jbpm.WorkflowTaskInstance.create(WorkflowTaskInstance.java:107) …
Am I doing something wrong here? Would you like me to provide more detail about this, or submit a Jira Issue?
Thanks in advance,
Luca
Labels:
- Labels:
-
Archive
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2008 01:31 PM
I added a Jira issue, just in case… 🙂
Leaving a note here for future memory :
https://issues.alfresco.com/jira/browse/ALFCOM-2253
Thanks, Luca
Leaving a note here for future memory :
https://issues.alfresco.com/jira/browse/ALFCOM-2253
Thanks, Luca
