How to write Transition logic in workflow based on clicked button on forms

Hi All,
When user clicks on Enable/Disable from Manage Accounts page it generates a work item for the manager to approve. The work item displays a form of datatable type with buttons approve and reject of action ‘next’ and ‘back’ respectively.
I want to add a logic in my transition like if approve is clicked it should transition to Step 1 if reject is clicked it should transition to step 2.
Can anyone help me in this

Try checking approvalSet variable of “Approve and Provision Subprocess” workflow.

Hi @sayandeep_zurich ,

You can try this. If it gets approved, proceed to Step 1. If it’s rejected, move to Step 2.

<Transition to="Go To Step 2" when="!approved"/>
 <Transition to="Go To Step 1" when="approved"/>

Do I need to return any thing from the form in the approval step?

Hi @sayandeep_zurich ,

For the transition process, there is no need to return any values from the form step.

It is not working for self. For other users it is working. Checked in task result getting error “void assignment at line:2”

This was a issue with the user, the solution is wotrking fine

You can use “approved” & “!approved” which is OOTB. Also, You can create your custom button in any forms, via direct in forms or in workflow, depends to your logic.
We used like this:

Form form = wfcontext.getWorkflower().getForm(<<formName>>);
 Form.Button stepWorkflowButton = new Form.Button("Manage", "Manage");
          stepWorkflowButton .setParameter("stepWorkflow");
          stepWorkflowButton .setValue("true");
          form.add((FormItem)stepWorkflowButton );

Basis of this you can use your transition :

<Transition to="<<any step>>" when="stepWorkflow"/>