cancel
Showing results for 
Search instead for 
Did you mean: 

How to get a custom properties from UserTask

juancarloscardo
Champ in-the-making
Champ in-the-making
Hi

How to get a custom properties from UserTask for example AcmeMoneyUserTask ?

Tks
6 REPLIES 6

martin_grofcik
Confirmed Champ
Confirmed Champ
Hi Juan,

have a look on org.activiti.engine.test.bpmn.event.end.TerminateEndEventTest#testParseTerminateEndEventDefinitionWithExtensions in activiti source.

Regards
Martin

Hello Martin

Thanks for the help, but I need the properties in the star event of the task.

Regards

vasile_dirla
Star Contributor
Star Contributor
Hi,
maybe execution listeners could help you ?
(now depends If i understood what you need)

http://www.activiti.org/userguide/
8.5.12. Execution listener
<code>
<userTask id="yourUserTask" >
    <extensionElements>
      <activiti:executionListener expression="bla.blah.YourExecutionListener"  event="start" />
    </extensionElements>
  </userTask>
</code>

Hi,
Thank you for answer my question, the case is that I have a UserTask extension form designer, with extension fields, I need get this extensions.

The diagram.

<userTask id="usertask1" name="Money user task" activiti:extensionId="org.agme.usertask.AcmeMoneyUserTask">
      <extensionElements>
        <activiti:accountNumber>1234567890</activiti:accountNumber>
        <activiti:maximumProcessingTime>1y 1mo 2w 3d 0h 0m 0s</activiti:maximumProcessingTime>
        <activiti:vipCustomer>true</activiti:vipCustomer>
        <activiti:accountType>senior</activiti:accountType>
        <activiti:expiryDate>2015-09-01 00:00:00</activiti:expiryDate>
        <activiti:hiddenField>test</activiti:hiddenField>
        <activiti:comments>Coments</activiti:comments>
        <activiti:withdrawlLimit>250</activiti:withdrawlLimit>
        <activiti:executionListener event="start" class="delegate.UserTaskDelegate"></activiti:executionListener>
        <activiti:taskListener event="create" class="delegate.UserTaskDelegate"></activiti:taskListener>
        <designer:editor-language xmlns:designer="http://activiti.org/designer/extensions" language="en">English account</designer:editor-language>
        <designer:editor-language xmlns:designer="http://activiti.org/designer/extensions" language="de">Deutsche account</designer:editor-language>
      </extensionElements>
    </userTask>


I've found a way to get them, there will be another way?

I get this way, with TaskListener.

@Override
public void notify(DelegateTask delegateTask) {

  //Find model by actual process
  BpmnModel model = delegateTask.getExecution().getEngineServices().getRepositoryService().getBpmnModel(delegateTask.getProcessDefinitionId());
 
  //Get mainProcess
  Process bpmnProcess = model.getMainProcess();
 
  //Find actual element in this case is userTask1
  FlowElement actualTask = bpmnProcess.getFlowElement(delegateTask.getTaskDefinitionKey());
  //Get de extesionElemen by element
  for (List<ExtensionElement> listElements : actualTask.getExtensionElements().values()) {
   for (ExtensionElement ee : listElements) {
    System.out.println("Name:" + ee.getName());
    System.out.println("Value:" + ee.getElementText());
   }
  }
}

Now I need define a Listener Task by everyone task, for not have that insert task Listener to every one task.
You know how?

Tks

vasile_dirla
Star Contributor
Star Contributor
Hi,
http://www.activiti.org/userguide/#_hooking_into_process_parsing

hooking into the parser during deployment would be a way to do it.

Hi
Thank you very much for your help, the link that you shared with me could implement what I needed.

Regards