Custom Task in Flowable 6.0.0

Hi,

As per our business requirement, We need to showcase a same set of information (form fields) on various tasks in different process definition. This fields might have default value which is different for each of the process definition.

In order to achieve this, we are trying to create our own custom task. This custom task will have a custom form (not the default form association) as a Property of that custom task. We are able to achive this while creating a process definition. But when we try to deploy the same, it is not working. Also we are not able to take it further.

To be specific,
In Flowable-modeler project, there is a component called a UserTask. We can drag & drop UserTask in flowable-modeler project.
We have created a Custom Task called “EquipmentTask” same as UserTask but with my custom properties. Those custom properties data I need to display while executing the actual process instead of default form.

I am looking for following things.

  1. Is my approach is proper? If not, please suggest one.
  2. What could be the issue for deployment? Is there anything which I am missing?

Let me know if you need more details.

Following are the technical Stack :
Flowable Version - 6.0.0
Java Version - 1.8
MySQL Version - 5.7

Regards,
Ankit

Hi Ankit,

That is a fine approach. So you changed the stencilset.json file right?
If you change the flowable-json-converter and add an extension element to the user task to identify it is a “special” user task you could use that information in the Flowable task application (if you are using that app). Otherwise you could use that information in your own app implementation.

Best regards,

Tijs

Hi @tijs

Thanks for your response.

Yes, we have changed the code in stencilset.json and other required files to achieve our required UI. You can see the attached screen shot (custom_properties_with_task.png) that we have implemented in our custom task.

Now, we need to showcase those custom properties data (e.g. Instruction Text etc…) while executing the actual process (Task).

So for that we are currently changing TaskInfo.java, Task.java, TaskEntity.java and TaskEntityImpl.java.

For saving the data into database, we have changed Task.xml (Added new column). Also we are changing SaveTaskCmd.java, DefaultFlowable5CompatibilityHandler.java (Method - convertToActiviti5TaskEntity) & other files.

I am looking for following thing :

  1. Is my approach is proper? If not, please suggest one.

Let me know if you need more details.

Following are the technical Stack :
Flowable Version - 6.0.0
Java Version - 1.8
MySQL Version - 5.7

Regards,
Ankit

Hi Ankit,

No that’s not the approach we would advise.
You can create extension elements on an Activity instance and elements will be exported as part of the BPMN XML. Then when you fetch the BpmnModel for the process definition, you can get the extension elements from the Activity instance and use them. No need to store them in the database in new columns.

Best regards,

Tijs

Hi @tijs,

Thanks for the reply.

I need some suggestion from your side that where i need to change in flowable project (For Ex. flowable-modeler, flowable-task, etc…) to create the Extension Element (Custom Task) which displays in UI OR should i add Extension Element from UI (Without changing code of flowable project). If yes, then please suggest the UI where i need to change.

Some example link Or suggestion highly appreciated.

Regards,
Ankit

Hi,

To use the extension element you would need to change the flowable-json-converter project to convert a Modeler property to an extension element in the BpmnModel. You can have a look at the UserTaskJsonConverter, which also sets a number of extension elements.

Then to be able to do something with the extension element in the BPMN XML, you would have to change the flowable-task-ui application where needed.

Best regards,

Tijs

Hi @tijs,

Thanks for your valuable support.

As you told, In flowable-json-converter project i have taken the reference of UserTaskJsonConverter (activiti-idm-assignee Property) and i am able to convert my Modeler property (custom property) to an extension element of UserTask in the BpmnModel. The value of that ExtensionElement is saved in model_editor_json field of act_de_model table. In flowable-ui-task application the value of assignee comes from the database and it displays in task-detail.html. So, i just stucked in how can i get my created UserTask Extension Element and display it in UI OR where i need to change in flowable-ui-task application?

Regards,
Ankit

Hi Ankit,

This depends a lot on what you want to do with the value in the user task extension element. Can you provide more details? In general, you need to write some Java logic to retrieve the user task extension element value using repositoryService.getBpmnModel to retrieve the BpmnModel, then BpmnModel.getFlowElement to retrieve the user task by its id, then there’s the getExtensionElements element on the retrieved FlowElement instance, to get all of its extension elements.

Best regards,

Tijs

2 Likes

can you share your demo?

Are you able to add the custom task successfully? As I am able to add it to UI but it is not working. Any help is appreciated.

@sauravInfoObject First of all, Sorry for late reply. Yes, I am able to add the custom task successfully in flowable. You can check my latest reply https://forum.flowable.org/t/custom-json-design/3349 in flowable forum.

If you are not getting OR you need more details for the same then let me know.

Thanks for approaching me.

Thank you so much, i gonna look then if i have any question i can write you.
@janiankit

1 Like

@janiankit - The above URL is not accessible. Can you help with that?

@RRSR or this, Flowable authorize person can help you. As this is open forum every user can see all the posts related to flowable.

No problem, i can share you the snapshots.

Capture

Capture1

Capture2

Hi janiankit,

can you guide me how you added custom property in flowable modeler, i have just added below code in stencilset_bpmn.json but dont know what to do next who to add custom properties and how to modify custom behavior or logic

 {
    "type" : "node",
    "id" : "CustomTask",
    "title" : "Custom task",
    "description" : "An automatic task with service logic",
    "view" : "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n......",
    "icon" : "activity/list/type.service.png",
    "groups" : [ "Activities" ],
    "propertyPackages" : [ "overrideidpackage", "namepackage", "documentationpackage", "asynchronousdefinitionpackage", "exclusivedefinitionpackage", "servicetasktriggerablepackage", "executionlistenerspackage", "multiinstance_typepackage", "multiinstance_cardinalitypackage", "multiinstance_collectionpackage", "multiinstance_variablepackage", "multiinstance_conditionpackage", "isforcompensationpackage", "servicetaskclasspackage", "servicetaskexpressionpackage", "servicetaskdelegateexpressionpackage", "servicetaskfieldspackage", "servicetaskresultvariablepackage", "skipexpressionpackage" ],
    "hiddenPropertyPackages" : [ ],
    "roles" : [ "Activity", "sequence_start", "sequence_end", "ActivitiesMorph", "all" ]
  },

Hi,

the example, how to add custom property into json model, can be found here:

After that you have to add conversions into json<-> model converter

Regards
Martin