cancel
Showing results for 
Search instead for 
Did you mean: 

Alfresco Workflow: How to set association value when update Task by REST Json?

amrorabi
Champ in-the-making
Champ in-the-making
Hello dears,

My application is interacting with Alfresco workflow by REST. There is a task having association to an object of type cmSmiley Tongueerson, 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:

<code>

<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>cmSmiley Tongueerson</class>
                    <mandatory>true</mandatory>
                    <many>false</many>
                 </target>
                </association>
            </associations>
        </aspect>
</aspects>
////////////////////////////////////////////////////////////////////////
1 REPLY 1

amrorabi
Champ in-the-making
Champ in-the-making
After deeply searching, This REST API doesn't support submitting associated object, it will see the object reference as String. So, I should do some work around in my process definition.