cancel
Showing results for 
Search instead for 
Did you mean: 

How to change UserTask Form Property dynamically

kolpona
Champ in-the-making
Champ in-the-making
Hello, I am new with activiti. I want to create a user task and only want to show the fields that has values. I tried several ways with no luck. Am I missing something here? Please help. My sample code for understanding my requirement:

<userTask id=“myUsertask" name=“Operate Item” activiti:async="true" activiti:exclusive="false" activiti:assignee="kermit">
      <extensionElements>
        <activiti:formProperty id="Lemar” name=“Leamr cost” type="string" variable="Lemar" readable="false" writable="false"></activiti:formProperty>
     <activiti:formProperty id="Armer” name=“ Armer cost” type="string" variable="Armer" readable="false" writable="false"></activiti:formProperty>
      ………
    <activiti:taskListener event="create" class=“…..OperateCreateEventListener"></activiti:taskListener>
      </extensionElements>
    </userTask>

then in OperateCreateEventListener:
……
List<FormProperty> formProperties = execution.getEngineServices().getFormService()
            .getTaskFormData(delegateTask.getId()).getFormProperties();
      for (FormProperty formProperty : formProperties) {
         if (valueList.contains(formProperty.getId())) {
            int index = formProperties.indexOf(formProperty);
            boolean isReadable = execution.getEngineServices().getFormService().getTaskFormData(delegateTask.getId()).getFormProperties()
                  .get(index).isReadable();
            log.info(formProperty.getId() +"is set to isReadable() =" + isReadable);
}

Because of readable="false", I am not getting the properties in FormProperty list. I also tried to remove the particular FormProperty from the list with no luck. I got 'true' when the remove method called, but then If I check the size of the list, it remains same. And also they all appear in the Task. I am kind of confused. Is there any other way  to do it? (Display only selective form properties).

Thanks.
Kolpona.




1 REPLY 1

kolpona
Champ in-the-making
Champ in-the-making
missing(not visible) snippet:
<userTask id=“myUsertask" name=“Operate Item” activiti:async="true" activiti:exclusive="false" activiti:assignee="kermit">
      <extensionElements>
        <activiti:formProperty id="Lemar” name=“Leamr cost” type="string" variable="Lemar" readable="false" writable="false"></activiti:formProperty>
   <activiti:formProperty id=“Armer” name=“Armer cost” type="string" variable="Armer" readable="false" writable="false"></activiti:formProperty>
  ………
  <activiti:taskListener event="create" class=“…..OperateCreateEventListener"></activiti:taskListener>
      </extensionElements>
    </userTask>