FormKey for Message based Start Events

89 views
Skip to first unread message

Matthias Brenner

unread,
Sep 28, 2015, 9:04:08 AM9/28/15
to camunda BPM platform contributors
My problem is, that I want to display a GUI at the moment the process is started. I think a formKey for the start event should solve my problem.

The process itself my provide several start events:
  • start new artifact
    A new artifact has to be entered with all it's properties
  • modify existing artifact
    An existing artifact has to be selected

To be able to address multiple start events in the process, they are modeled as message start events.


As you see, there are reasons for different GUI depending on the start event. The remaining process can be the same.


How can I retrieve the form key from the start event?


First I tried to set up a parse listener for start events and check, whether there is a form key. If it is defined I could present the GUI. Unfortunately I could not find any entries in the API to retrieve the formKey. I found it on the XML elements. In the next step I looked through the code of the parser and recognized, that the parser does only parse the formKey for the user task and leaves my alone for the start event (hope that I'm wrong).


I asked Daniel how to retrieve the formKey. I said, I could use the method org.camunda.bpm.engine.FormService.getStartFormKey(String processDefinitionId). This seems to work only for ordinary start events. Since my problem case requires multiple start events, I use message based start events.


Please provide me some information how I can retrieve the form key for a message based start event.

Philipp Ossler

unread,
Sep 29, 2015, 5:10:27 AM9/29/15
to camunda...@googlegroups.com
Hi Matthias,

the key of the start form is resolved by DefaultStartFormHandler [1] which is called by the parser [2] in method parseStartFormHandlers(). The FormService use this handler to retrieve the key of the start form of the process definition [3].
However, a process definition could only have one start form. There are serval ways to resolve your problem:
* use an extension element to define the form key on the start events and access it via model api [4]
* use two process definitions one for each start event. After start, the process instance arrive a call activity or send a message event to call the similar behavior.
* use an user tasks after each message start event
* use one start event with form to choose the action and then arrive one of the two user tasks to input the data 

Greetings,
Philipp 


Matthias Brenner

unread,
Sep 29, 2015, 6:57:25 AM9/29/15
to camunda BPM platform contributors
Hello Philipp,
I implemented a parse handler for the start event. I lookup the form key in the DOM tree. My implementation is working. But it is not nice.

From my point of view: The message start event is provided with a form key, but no possibility to access it via the Camunda APIs. So I think Camunda is not consistent at this point. You allow to enter the form key (modeller), but there is no help to extract it (engine).

In the moment I understood, that there is no Camunda support, I was able to write my own implementation. But I think Camunda should be consistent. If the start event is message based, do not allow to provide a form key (bad for me, because I use it) or provide the functionality in the engine to access the form key (would be very nice ;-) ).

Thanks for the code explanation. Now I understand how the form key is accessed.

Another question to the extension elements. If I would implement such an extension element for the message based start event, it would be possible for me to extract the form key during a execution listener?


Kind regards
Matthias

Philipp Ossler

unread,
Sep 29, 2015, 8:21:39 AM9/29/15
to camunda...@googlegroups.com
Hi Matthias,

you can access the form key using the model api:
BpmnModelInstance bpmnModelInstance = repositoryService.getBpmnModelInstance(processDefinitionId);
Collection<StartEvent> startEvents = bpmnModelInstance.getModelElementsByType(StartEvent.class);
StartEvent startEvent = startEvents.iterator().next();
String formKey = startEvent.getCamundaFormKey();


Additionally, you can get the form key using the FormService#getStartFormKey(processDefinitionId), also for message start events. But this works only if there is one start event (e.g. initial start event) and not more. [1]

Greetings,
Philipp

Reply all
Reply to author
Forward
0 new messages