How to Create Conditional Calculation In Mini Apps Or WhatsApp Native Flows ?
Last updated
Last updated
Powered By Automations
A registration form for an event is used as an example to demonstrate how to create conditional calculations in a mini app. The form includes fields such as name, father's name, district, WhatsApp number, and the number of packs attending the event. The "number of packs" field is a dropdown with options 1 to 4, set to numeric values. Fields' visibility in the visitor details screen is conditional, based on the selected number of packs.
The "stay required" field can add a charge of 2500 rupees if selected as yes, impacting the extra data field. In the summary field, conditional calculations are performed on the totals and stay details.
ChatGPT can assist in writing the logic for these calculations using an if-else component, necessitating a ternary operator in JavaScript. It is crucial to ensure the correct formula, especially with text fields, considering various scenarios.
Logic is written by checking person field states, assigning values based on conditions. More complexity can be added using multiple conditions. The generated formula is modified to replace field names with previous screen variables.
Implement the formula by creating a data source on the same screen. After writing and saving the formula, perform a test calculation to ensure correct mapping and functionality.
Summarize the process as creating a data store, generating and modifying a formula, and implementing it to enable conditional calculations. Despite initial complexity, formulas utilize simple logic with dynamic fields.
Mini App Template: DASHBOARD_URL /products/flows/share/8c7400c2-92d2-4b49-8809-dd21136c17ba