Bpm process form param

Hello!

I’d like to ask that how can I get a custom ProcForm param?

I made a new bpm ProcForm and I would like to get the edited entity from the process in the new form’s controller.
Is it possible, and if it is, how can I do that?

Thanks for the answers.

Hi,
To get the edited entity you probably need to get entity id from the process variables. Each time the new process is started the entity id is written to the process variable called entityId.

To get its value in the process form you may try to do something like this:

@UiController("task-contract-approval-form")
@UiDescriptor("task-contract-approval-form.xml")
public class TaskContractApprovalForm extends Screen implements ProcForm {

    @Inject
    protected TextField<String> contractField;

    @Inject
    protected ProcessVariablesService processVariablesService;

    @Inject
    private DataManager dataManager;

    //ProcInstance can be get from window params
    @WindowParam
    private ProcInstance procInstance;

    @Subscribe
    protected void onInit(InitEvent event) {
        //get the entityId process variable
        UUID entityId = (UUID) processVariablesService.getVariable(procInstance.getActProcessInstanceId(), "entityId");
        
        //load the entity with the given id
        Contract contract = dataManager.load(Contract.class)
                .id(entityId)
                .one();
        
        //use the loaded entity
        contractField.setValue(contract.getNumber());
    }

Unfortunately, there was an issue - the ProcessVariablesService cannot be injected to the screen controller. It is fixed and the fix will appear in the next 7.1. bugfix release. So the snippet above will only work after bugfix release is published.