Change Business Process Flow Based on Form Type Using Java Script. | CloudFronts

Change Business Process Flow Based on Form Type Using Java Script.

Posted On March 9, 2021 by Vidit Gholam Posted in 

There are situations where you might need different business process flows based on the form type you choose let us take an example.

Consider you want a Business Process flow on the lead entity Such that

  1. Lead form will show –BPF with stage Discover, Demo, Propose
  2. Sales Lead form will show – BPF with stage Discover, Requirement Gathering, Qualify
  3. The case be achieved by doing the following.

Lets begin with the implementation.

Solution –

Step 1: Make a Solution for your customizations and add the lead entity in your solution.

Step 2: Make 2 main forms for the lead entity namely “Lead form” and “Sales Lead form

Step 3: Go to process – > Add a new process -> names It Lead creation.

Step 4: In the same solution under lead entity add a field of type single line of text namely “Form Type”.

Step 5: Add this new field on the lead form and the sales lead form.

Note : This field will carry the form type of the form hence will be kept hidden and locked on both the forms.

Step 6 : Next step is to get the form type in our form type field to achieve this we will use a web resource that     

is a java script code

Step 7 : By doing so we successfully bring the form type written in our single line of text field.

Step 8 : Next step is to create a business process flow in the solution go to process and make a new business process flow.

Step 9 : The above snapshot shows the business process flow to achieve the functionality here the create stage we take the form type as a parameter this is then passed to the condition to check the form type

Step 10 : So, if the form type is Lead form it will be true and take business process flow for lead form.

Step 11 : Else it will be false and will take the business process flow for the sales lead form.

Note: – Make sure to add the business process flow as an entity to the solution and select the form and the business process flow in the site map of the app designer.

Java Script code : (Onload of the Form)

ChangeBPFByType = (executionContext) => {


    try {

        let formContext = executionContext.getFormContext();

        const selectedFormName = formContext.ui.formSelector.getCurrentItem().getLabel();

        const getFormIdFromTxtBox = formContext.getAttribute(“cfs_formtype”).getValue();


        if ( == “”) {



        else {

            var getAllForms = formContext.ui.formSelector.items.get();

            let navigateFormGuid = “”;

            for (var i = 0; i < getAllForms.length; i++) {

                if (getFormIdFromTxtBox == getAllForms[i]._label) {

                    navigateFormGuid = getAllForms[i]._id.guid;




            if (getFormIdFromTxtBox != selectedFormName) {




    } catch (e) {

        alert(“Something went wrong please try again later”);



Hope that helps.!

Share Story :