Screen navigation based on userregistration form using webapp

You could specify the form fields and some basic validation, such as allowed values and mandatory fields to your process like this:

 <bpmn:startEvent id="StartRegistration" name="Start registration">

      <camunda:formField id="AccountType" label="Account Type" type="enum">
       <camunda:value id="buyer" name="Buyer" />
       <camunda:value id="reseller" name="Reselller" />
      <camunda:formField id="Country" label="Country" type="string">
        <camunda:constraint name="required" />

The rest API (endpoint 2. above) will give you a 400 if the form is invalid. The next form logic based on user input can be defined in the process using gateways (see attachment).

registration.bpmn (7.4 KB)

These are just some ideas, you have many option in Camunda such as using DMN in your workflow if you have complex rules for the form sequencing or specify the forms and process separately.

I dont want to create a form in camunda.
I have a webapp which has 4 steps of registration form in angular. Using camunda workflow I have to navigate the steps in angular based on response for each step from camunda.

Right, you don’t have to explicitly specify the form in your process. Just post your values to the engine so it can decide about the next step:

  1. POST /process-definition/{id}/start --> Attach any variables
  2. GET /task?processInstanceId={instance_id} --> Returns the task_id for the next step
  3. POST /task/{id}/complete --> Go to to 2. until process complete

The key is step 2. above where you request the next step in the process instance from Camunda, be it a task form or just the name of the next task/step.

1 Like

But how do I navigate to Step2 or Step3 in my UI based on the condition validated in Step1 form variables sent to camunda.
How can I get the response for Step1 Post method where I send the variables to camunda and get the next screen in my external webapp such as Step2 or Step3.
Like how do I map the response from camunda for Step1 to the next Step in UI

In angular template:

<div *ngIf="currentStep === 'step1'">form for step1 goes here</div> 
<div *ngIf="currentStep === 'step2'">form for step2 goes here</div>
<div *ngIf="currentStep === 'step3'">form for step3 goes here</div>

In angular component:

currentStep = 'step1';

 // call service to POST /process-definition/{your_registration_process_id}/start
 // fetch process instance id from response into processInstanceId

 // call service to POST /task/{currentTaskId}/complete

  // call service to GET /task?processInstanceId={processInstanceId}
  // fetch task id from response into currentTaskId
  // fetch task name into currentStep 

Thank you so much,
I just need one more help, sorry for the inconvenience.
Actually what I am doing is the scenario below.
As I said I have registration steps in Angular.
I am fetching the form values from Step1 to java and sending the values to camunda using rest API from java class instead of directly calling in angular.
Now validating the field say any values which i sent to camunda from java for Yes or No and have to call the step2 or step3 from the response given by camunda to java code and from java I have to map the response to particular step in angular2.
Is this possible?

Its a bit of a guessing game what you want to do. Its clear now that you want to build your forms in
Angular and route the requests to Camunda trough the Java backend. What exactly do you want Camunda to do for you and what response do you expect from Camunda? Did you already model a process that shows what you want to achieve and that you could share?

You are exactly right.
I want camunda to validate the field or fields which is sent in Step1 and based on the validation or logical function results send the response whether to call step2 or Step3 which has to be mapped to angular UI from java.
For Example :
I have to create customer form with 3 steps and each step which has many fields where one field in Step1 has a field with name existingClient. When the user send Y or N as a value for the field, based on the value validate the condition in camunda and send the response to call the step2 screen for value Y or Step3 screen for value N to java and map that step in angular.
Please find the process attached.

customer.bpmn (7.2 KB)

Alright, Camunda will not directly give you that kind of response after completing a step. It just closes the task and continues the process execution. In fact, the approach I outlined does it in two steps:

After submitting the form in step1 with a existingCustomer variable there is a running instance of that process. That instance will continue executing and then stops waiting either at step2 or step3 depending on the existingCustomer variable. Thus, you will then have to query for the currently open task on that process instance and Camunda will tell you if there is a step2 or step3 task pending which allows you to present the appropriate screen.

So what will be the response after executing the Step1 with existingCustomer variable so that i can call the appropriate screen?

Thank you so much for the support.
I have one issue.
The Rest api GET /task?processInstanceId={processInstanceId} when called from java gives the response only once. If I call api again the response is empty.
Only after i restart my java application it gives me the response for the first request again it fails when it is called second time.So, how can i solve this?

Sounds odd. What does it return in terms of http status code after the second call? Is there anything in Camunda’s logs that looks like an error? What does your Java code and the process look like?

Thank you.
I got the solution for it. There was a problem with the process.
Now I am trying to call the approval process.
The flow would be like say after I submit the form, there will be a group of approver.
I have to call the next step only if the users in the group approve the form submitted like if there are 2 users in that group, then until both the users approve it should not call next step.
How can i do this?

You will have to create multiple tasks, either with a parallel gateway or a multiple-instance activity:

Actually task will be one where the task will be to approve the request. But it has to be approve my 2 persons who are in the group assigned to that task.
So, until all persons in group are approved it should not go to other step.

Understood, it’s the same approval task for both. Still, technically it will be two different tasks assigned to different users through parallel gateway or multiple-instance.

Can you help me on How to validate for multiple fields using expression in camunda?

Is it possible to add a custom variable to the response along with the existing json response data when the rest api is called in camunda.

How to go back to step2 from step3 in camunda so that it will be with the current step in UI?
For example as as said above with screenflow, the user selects next so that goes to next step but i need to modify the previous screen again but camunda task points to the current instaed it also should go back and point to the previous step