Question

My application is interacting with Alfresco workflow by REST. There is a task having association to an object of type cm:person, its value should be collected form the end user -to be used as assignee of the next task-. How can I set this value by REST ??


I tried to send HTTP "PUT" request (content-type:application/json) on URL

http://localhost:8080/alfresco/service/api/task-instances/activiti$11102

and body request is:

{ "cio_employee": "workspace://SpacesStore/bcb9817f-5778-484b-be16-a388eb18b5ab" }

where "workspace://SpacesStore/bcb9817f-5778-484b-be16-a388eb18b5ab" is the reference of admin person, but when I end the task (by REST also), Alfresco throws error:

...

Caused by: org.activiti.engine.ActivitiException: Unknown property used in expression: ${cio_employee.properties.userName} ... Caused by: org.activiti.engine.impl.javax.el.PropertyNotFoundException: Could not find property properties in class java.lang.String


Below is the task and its model definition:

//User Task:

<userTask id="assignHandler" name="Assign Employee" activiti:assignee="admin"
    activiti:formKey="cio:assignEmployeeTask">
    <documentation>Please, Assign employee to the next task</documentation>
    <extensionElements>
          <activiti:taskListener event="complete" 
               class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
             <activiti:field name="script">
            <activiti:string>
                   execution.setVariable('cio_employee', 
                               task.getVariable('cio_employee'));
             </activiti:string>
             </activiti:field>
          </activiti:taskListener>
    </extensionElements>
</userTask>

/////////////////////////////////////////////////////////// //Model ...

<types>
 ...
  <type name="cio:assignEmployeeTask">
    <parent>bpm:workflowTask</parent>           
    <mandatory-aspects>
        <aspect>cio:employee</aspect>
    </mandatory-aspects>            
  </type>
 ...
</types>
...

<aspects>  
    <aspect name="cio:employee">
        <associations>
            <association name="cio:employee">
                <source>
                   <mandatory>false</mandatory>
                   <many>false</many>
                 </source>
                 <target>
                    <class>cm:person</class>
                    <mandatory>true</mandatory>
                    <many>false</many>
                 </target>
                </association>
            </associations>
        </aspect>
</aspects>

////////////////////////////////////////////////////////////////////////

Was it helpful?

Solution

After searching deeply, you will need to send POST request on

http://localhost:8080/alfresco/s/api/task/[taskId]/formprocessor

with body:

{
  "assoc_cio_employee_added": "workspace://SpacesStore/bcb9817f-5778-484b-be16-a388eb18b5ab"
}

and for removing use the key "assoc_cio_employee_removed"

https://wiki.alfresco.com/wiki/Forms_Developer_Guide

Hope it may help someone.

Alfresco Version 4.2.e

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top