Starting BPM process - how to mix process variables from input dialog and pre-defined process variables

In project I work on we have an entity browser screen for some entity (let’s call it Work), from which I want to call different BPM processes for these entities. Processes in question have Input dialogs with parameters defined in each process individually in their starting node. Also they have one common parameter - Work process is called for, which is already defined by the row in entity browser, for which BPM-calling action is triggered. How exactly should I call process exectution to correctly pass selected Work into it and summon Input dialog for process-dependent parameters at the same time?

If I use RuntimeService.startProcessInstanceByKey(String processDefinitionKey, String businessKey, Map<String, Object> variables) method, I can pass selected Work as parameter, however input dialog in starting node is skipped.

If I use ProcessFormScreens.createStartProcessForm(ProcessDefinition processDefinition, FrameOwner frameOwner) method, I see input dialog of starting node and can input other parameters, however there is nowhere to pass selected Work entity.

Jmix version 1.6.2 (plugin version 2.0.4-223), Intellij Idea Community Edition 2022.3.3

Hello,

one solution is to start the process with RuntimeService.startProcessInstanceByKey, and modify your process so that the start node can be ignored. Whatever input or defaults you need from the start node you can do with one or combination of :
a) open an input dialog view, and then pass the variables with Map<String, Object> variables when starting the process
b) after the start node, to add some defaults, add an initialization groovy script with statements like this

status = 'IN PROGRESS'
execution.setVariable('Status', status)

c) after the start node, add normal input dialog human task for user to enter desired values

Kind regards,
Mladen

Thank you for your answer.

Unfortunately, solution “C” is how we are doing it currently - pass selected Work with RuntimeService.startProcessInstanceByKey on process start and fill everything else in user task. Which requires to go to different panel called MyTasksBrowse to actually fill user-defined variables. Solution “A” requires individual dialog and individual starting action for every process. “B” does not fit because we need not defaults but values set by user for every execution. Guess will will have to keep current variant.

Input Dialogs can be overridden and modified as needed, that’s what I did, but some complexity is involved.
How about using Jmix process forms instead of input dialogs? That way you can add navigation to the next form without going to MyTasksBowse.