menu-icon
Bit Assist Menu Icon

Conditional Logic

Estimated reading: 9 minutes 472 views

Bit form – Conditional Logic

Conditional Logic in Bit Form is a set of actions (Success Message/ Error Message, Redirect URL, WebHook, Email Notifications, Integration, Double Opt-in, and field updates) that are executed when certain specified conditions are met. These rules automate the process of Success Message, Redirect URL, WebHook, Email Notifications, Integration, Double Opt-in, and field updates when a rule is triggered.

A workflow rule consists of the following elements:

1. Action Run When

Specify when the rule should be triggered for a record. There are four options:

Record Create/Edit

Executes the rule when records are created and or existing records are modified. See the example below :

Record Create

Executes the rule when records are created. It doesn’t work for Edit, and Delete. See the example below :

Record Edit

Executes the rule when existing records are modified. It doesn’t work for create, and delete.

Record Delete

Executes the rule when certain records are deleted. Only Email Notifications and Webhooks can be associated with such a rule.

2. Action Effect

– Always

The “Always” action serves to dynamically assign a value within a form during its loading process. Additionally, it provides the capability to show, hide, disable, and enable form elements.

Actions accessible for the “Always” condition during the creation or editing of a form load include the option.

  1. Field value update
  2. Disable Field
  3. Enable Field
  4. Readonly Field
  5. Writeable Field
  6. Hide Field
  7. Show Field
  8. Label value update of Field
  9. Sub Title value update of Field
  10. Placeholder
  11. Helper Text value update of Field

See the example below:

In the above example, the form will always set the Phone number “123456789” When the First Name Starts with “B” and the Last Name Ends With “s” then the Email and Phone field will be disabled. Many kinds of logic are used for On Form Load such as Equal, Not Equal, Is Null, Is Not Null, Contain, Not Contain, Greater Than, Less Than, Start With, Greater Than Equal, Less Than Equal, Start With, End With.

– Only On Form Load

The Only On Form Load action is used to dynamically alter a Form when it is loaded. The Form actions On Form Load are executed when the Form is loaded by a user.

When a page is loaded and you want to pre-filled some field value and can also run a Conditional Logic to update value, show, hide, disable, and enable fields, and more.

There are two ways to pre-filled a value:

  1. Use an initial field value in field properties in the form builder.
  2. Use the parameter in the URL.
  3. Parameter in the URL: website_url?field_api_name=field_value

Example: “https://www.bitapps.pro/test/?b1-2=Bit Apps”

Conditional Logic action for Only On Form Load: on a form load while created or edited following actions are available.

  1. Field value update
  2. Disable Field
  3. Enable Field
  4. Hide Field
  5. Show Field
  6. Readonly Field
  7. Writeable Field
  8. Label value update of Field
  9. Sub Title value update of Field
  10. Helper Text value update of Field

See the example below:

In the above example, after the form loading Email will be “[email protected]” and the Message will be disabled. Many kinds of logic are used for On Form Load such as Equal, Not Equal, Is Null, Is Not Null, Contain, Not Contain, Greater Than, Less Than, Start With, Greater Than Equal, Less Than Equal, Start With, End With.

– Only On Field Input

The Only On Field input is a client-side action that will be called whenever the value of a field is modified by the user. It is used to improve the usability of a form by validating field data even before it is submitted or displaying other field values based on the value specified in this field. The On-Field input is executed before the changed data is persisted in the database.

When a form is created or edited a user/visitor puts value in a field based on that you may want to trigger an action. The following actions are available for on-field user input:

  1. Field value update
  2. Disable Field
  3. Enable Field
  4. Hide Field
  5. Show Field
  6. Readonly Field
  7. Writeable Field
  8. Label value update of Field
  9. Sub Title value update of Field
  10. Helper Text value update of Field

See the example below:

In the above example, if First Name is equal “Bit” and Last Name is equal “Apps” then the Email will be [email protected] and the Email field will be disabled Many kinds of logic are used for Field Input such as Equal, Not Equal, Is Null, Is Not Null, Contain, Not Contain, Greater Than, Less Than, Start With, Greater Than Equal, Less Than Equal, Start With, End With.

On Form Validate

This action is executed when a user submits the form to the server before the user data is stored in the database. The script runs on the server side, and it has access to all the inputs the user entered. Only a message can be associated with such a rule.

In the above example, if the First Name starts with “B” or the Last Name ends with “S”, a message will be shown from the created confirmation message. Many kinds of logic are used for Form validation such as Equal, Not Equal, Is Null, Is Not Null, Contain, Not Contain, Greater Than, Less Than, Start With, Greater Than Equal, Less Than Equal, Start With, End With.

– On Form Submit

On Form, Submit is used to execute actions when a new record is successfully submitted to the database or when an existing record is updated or deleted from the database. It works in both situations when new data is submitted or edit old data. Action on “On form submit” can be triggered with or without condition. The following actions are available in the On form to submit:

  1. Success Message
  2. Redirect URL (does not work on edit)
  3. Email Notification
  4. Integration
  5. Field value update
  6. Double Opt-in

See the example below:

In the above example, if First Name is Null And Last Name Is Not Null then a success message will be shown from the created confirmation message and the page redirects to “https://bitapps.pro/”. Many kinds of logic are used for On Form Submit such as Equal, Not Equal, Is Null, Is Not Null, Contain, Not Contain, Greater Than, Less Than, Start With, Greater Than Equal, Less Than Equal, Start With, End With.

Workflow condition: You can create multiple conditions in a workflow rule. Each condition consists of two elements. One is specifying which records should be triggered i.e. all records or the records that match the criteria. Another is adding the criteria based on which it should be triggered.

3. Action Behavior

Always: The action in a workflow executes for all records by default when the action behavior field is set as Always.

Actions accessible for the “Always” condition during the creation or editing of a form load include the option.

  1. Field value update
  2. Disable Field
  3. Enable Field
  4. Readonly Field
  5. Writeable Field
  6. Hide Field
  7. Show Field
  8. Label value update of Field
  9. Sub Title value update of Field
  10. Placeholder
  11. Helper Text value update of Field

In the above example, after the form loading Email will be “[email protected]” and the Email will be disabled.

Condition: Executes the workflow via conditional logic. The rule will be triggered for the records that meet the criteria.

In this condition, you can use many kinds of logic. Here are some examples of conditions:

In the above example, if the workflow is working, the continent value is set to “Asia”. Although “language”=”Bangla” does not match the workflow is working. Firstly the workflow checks whether the first two conditions (“country”=” Bangladesh” and “City”=” Dhaka”) are met, if met then it checks the next condition. We used OR logic for the next condition. We set “language”=”Bangla” in the workflow but filled up this field “English”. Since we used OR for this condition, if not the condition is met then the workflow will check the next condition. We used AND for the next condition. For this, it must be met, or the workflow will not work.

In the above example, if the workflow is working, the continent value is set to “Asia”. Although the first two conditions (“country”=” Pakistan” and “City”=” Islamabad”) do not match the workflow is working. Because this time the workflow checks the condition by group. Firstly the workflow checks whether the first two conditions (“country”=” Bangladesh” and “City”=” Dhaka”) are met, since we used OR after those two conditions, if not those conditions are met then the workflow will check the next condition. We use OR logic for the next condition. Then it checks whether the last two conditions are met. If matches, the workflow will work.

In the above example, if the workflow is working, the continent value is set to “Asia”. The workflow is not working. Firstly the workflow checks whether the first two conditions (“country”=” Bangladesh” and “City”=” Dhaka”) are met, if match then it checks the next condition. We used OR logic for the next condition. Since we used OR for this condition, if not the condition is match then the workflow will check the next condition.

We used AND for the next condition. Since we used AND for this condition, it must be met or the workflow will not work. We set “Sea port”=” Chittagong” in workflow but filled up this field “Karachi”. This condition isn’t a match, for this the workflow isn’t working.

#Calculation :

In Bit Form, you can use many kinds of mathematical calculations. Bit form allows Addition, Subtraction, Multiplication, and Division. You can calculate via form field value or custom value. See the example below :

In the above example, the sum of all fields’ values is shown. If you want to calculate with field values, you have to follow the syntax. Here’s an example syntax: ${b3-3}+${b3-2}+${b3-4}+${b3-6}. Start with the ‘$’ sign then have to wrap the field key in ‘{}’. Here “b3-3”, “${b3-2}”, ${b3-4}, ${b3-6} are field keys.

In this example, you have the option to add initial values for each field. You can also calculate the values using specific formulas. For example, the Electricity Bill is calculated as (10+10)*2, the Gas Bill is calculated as (10*10)+2, the Internet Bill is calculated as 10/10-4, and the Telephone Bill is calculated as 20-10+4.

  Note

Notice: Bit Form allows only the number field for calculation.

Share this Doc

Conditional Logic

Or copy link

CONTENTS