Update Workflow Task Property via JavaScript
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-10-2013 05:39 AM
Hi all,
How can I update a task property using JavaScript? The code below does not work:
<javascript>
var task = workflow.getTask("jbpm");
task.properties["wf:destinationUser"] = "new.user";
task.save();
</javascript>
Anyone?
Sure it must be simple, but i can find it anywhere.
Thanks!
João
How can I update a task property using JavaScript? The code below does not work:
<javascript>
var task = workflow.getTask("jbpm");
task.properties["wf:destinationUser"] = "new.user";
task.save();
</javascript>
Anyone?
Sure it must be simple, but i can find it anywhere.
Thanks!
João
Labels:
- Labels:
-
Archive
4 REPLIES 4
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-10-2013 07:40 AM
Hello,
you can't update the properties of a task like you would on a node. What you should be able to do is the following:
There is no need to call save() as the assignment will already trigger the update in the database. Please note that this code, while apparently trivial and using a seemingly unnecessary re-assignment, is required due to the way the JavaScript environment and the involved Java objects interact.
Regards
Axel
you can't update the properties of a task like you would on a node. What you should be able to do is the following:
var task = workflow.getTask("jbpm");var properties = task.properties;properties["wf:destinationUser"] = "new.user";task.properties = properties;
There is no need to call save() as the assignment will already trigger the update in the database. Please note that this code, while apparently trivial and using a seemingly unnecessary re-assignment, is required due to the way the JavaScript environment and the involved Java objects interact.
Regards
Axel
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-10-2013 06:24 PM
Hello Alex and many thanks for the reply.
I tried the code that you suggested, but does not work. More specifically the last line. I get the following error:
<javascript>
Java class "org.alfresco.repo.workflow.jscript.JscriptWorkflowTask" has no public instance field or method named "properties"
</javascript>
I suppose I can "get", but I can't "set"…
Any ideas?! …
Thanks again,
João
I tried the code that you suggested, but does not work. More specifically the last line. I get the following error:
<javascript>
Java class "org.alfresco.repo.workflow.jscript.JscriptWorkflowTask" has no public instance field or method named "properties"
</javascript>
I suppose I can "get", but I can't "set"…
Any ideas?! …
Thanks again,
João
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2013 04:10 AM
Hello,
try <blockcode>task.setProperties(properties);</blockcode> instead. It appears that in this instance, the <blockcode>task.properties</blockcode> is mapped to the getProperties() method, but the assignment is not mapped to the setProperties() equivalent. This is also an oddity of the JavaScript-Java boundary - the get/set methods don't always align properly based on parameter type definition and runtime resolution.
Regards
Axel
try <blockcode>task.setProperties(properties);</blockcode> instead. It appears that in this instance, the <blockcode>task.properties</blockcode> is mapped to the getProperties() method, but the assignment is not mapped to the setProperties() equivalent. This is also an oddity of the JavaScript-Java boundary - the get/set methods don't always align properly based on parameter type definition and runtime resolution.
Regards
Axel
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2013 07:21 PM
It works! Thanks for the help Alex… and the explanation …
Regards,
João
Regards,
João
