cancel
Showing results for 
Search instead for 
Did you mean: 

[javascript] Take Ownership of a pooled task

granddams
Champ in-the-making
Champ in-the-making
Hi all,

i'd like to create my own javascript webscript which could give ownership of a pooled task to a specific user. Simple idea isn't it?
But i'm looking for a few days, and i'm a bit lost with tracks i found.


* the following line doesn't work
workflow.getTaskById(PooledTaskid).properties["cm:owner"] = "admin";
Is it really the property "owner" which i've to update?

* How can i use the method "setProperties" if it really exists in the workflow api?
What about method "setPooled" in the workflow api? Do you have any exemples of how i can use it?

* http://forums.alfresco.com/en/viewtopic.php?f=34&t=23648
http://forums.alfresco.com/en/viewtopic.php?f=34&t=19041 (last post)
these posts use a java backed webscript which seems to work, but i search a solution with javascript api cause i suck in java…

Any ideas?

And if i'm REALLY obliged to use java, i work on alfresco 3.4e and there's just a sdk for 3.4d, will i be in troubles?
One solution could be to create a java backed webscript which makes what i want and a seconde solution is perhaps like in this french post (http://blog.starxpert.fr/?p=255) to extend the javascript api with my own class.
I don't know which class i've to extend and how to use code of the post http://forums.alfresco.com/en/viewtopic.php?f=34&t=23648
Map<QName, Serializable> params = new HashMap<QName, Serializable>();
params.put(ContentModel.PROP_OWNER, owner);
WorkflowTask updatedTask = workflowService.updateTask(taskId, params, null, null);  
Moreover, since 2009 the code could have change, isn't it?

Any help would be very appreciated!
1 REPLY 1

granddams
Champ in-the-making
Champ in-the-making
Hi all,

for information, i still don't know how to do this with javascript API, but i tried to make a java-backed webscript andfinaly it works!
So if you want to try it in java:
:arrow: create a java class

package org.alfresco.wftaskproperties;
public class UpdateTaskProperties extends BaseScopableProcessorExtension
{
   private WorkflowService workflowService;
   
   public void setWorkflowService(WorkflowService workflowService) {
      this.workflowService = workflowService;
   }
      
public void setTaskOwner(String taskId, String owner) throws IOException {
       Map<QName, Serializable> params = new HashMap<QName, Serializable>();
      params.put(ContentModel.PROP_OWNER, owner);
      workflowService.updateTask(taskId, params, null, null);  
   } 
}
build a .class with it and place it in Alfresco\tomcat\webapps\alfresco\WEB-INF\classes

:arrow:  create a bean in Alfresco\tomcat\shared\classes\alfresco\extension\myNewBeans-context.xml
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>

<beans>
   <bean id="updateTaskProperties" parent="baseJavaScriptExtension"
        class="org.alfresco.wftaskproperties.UpdateTaskProperties">
        <property name="extensionName">
            <value>updatetaskproperties</value>
        </property>
        <property name="workflowService">
            <ref bean="WorkflowService"/>
        </property>
   </bean>
</beans>

And as said in the post http://forums.alfresco.com/en/viewtopic.php?f=36&t=35627 you just have to put
updatetaskproperties.setTaskAssignee(taskid, owner);
and it's done!