Dynamic calculation of price based on the calculated distance

Requirement

Calculate the cost of a taxi or hired car based on distance.

Use Case

A cab booking application calculates and displays the approximate cost of a trip based on pickup and drop-off addresses, after which the user can choose to book the ride in the Rent Requisition form by clicking a button.

Steps to follow

1. Create two forms with the following details:
 Form Form Link Name Field Type Field Name Field Link Name Rent Requisition Rent_Requisition Name Name Name Phone Phone Phone_Number Date-Time Travel Date & Time Travel_Date_Time Single Line Starting Point Starting_Point Single Line Drop Drop Booking Booking Single Line Starting Point Starting_Point Single Line Drop Drop Decimal Distance Distance Currency Price Price

2. Duplicate the Booking form to create a stateless form. Rename it Booking Estimate. We are using a stateless form because we are just using it to display the estimate. Some customers may just browse or check for the price.

3. Click on the Form Properties icon in the form builder header of the Booking Estimate form.

4. In the slider, remove the default buttons: Submit and Reset.

5. Create a button by clicking Add Button.

6. A new button named Button is created. Rename it to Book Now! as shown below, by clicking the three dots to the right of the button name.

7. In the same way, create a button named Calculate Price.

8. Create a workflow on the Booking Estimate form, to be executed upon loading the form, to disable the Price and Distance fields.

9. Click Add New Action. Add the below code to disable the Price field:
1. disable Price;
2. disable Distance;

10. To calculate an estimate for the trip based on the distance traveled, create another workflow to execute when the Calculate Price button is clicked.

11. Click Add New Action and add the below code to calculate Distance and Price. We are using the Zoho Maps Deluge method to find the distance between two locations.
1. //Calculate the distance between Start and Drop in km. We are using trim() to remove any spaces in the Starting Point and Drop
2. dist = round(zoho.map.distanceBetween(input.Starting_Point.trim(),input.Drop.trim(),"KILOMETRE"), 2);
3. //Assuming driver cost to be Rs.350
4. driverCost = 350;
5. //Assuming the driving cost to be Rs.17/km
6. ratePKm = 17;
7. //Calculating the prime estimate
8. price = round(driverCost + (dist * ratePKm) , 2);
9. //Since clicking the button refreshes the form, we are reopening the form after calculationÂ¯with the values.
10. openUrl("#Form:Booking_Estimate?Starting_Point=" + input.Starting_Point + "&Drop=" + input.Drop + "&Distance=" + dist + "&Price=" + price , "same window");

This will display the estimate of the cost of the journey.

12. Create a workflow for booking the cab when the Book Now! button is clicked after the estimate is shown.

13. Click Add New Action and click Deluge Script. Add the below script to open the Rent Requisition form with the Starting_Point and Drop fields already populated.
1. openUrl("#Form:Rent_Requisition?Starting_Point=" + Starting_Point + "&Drop=" + Drop, "same window");
The customer will enter the Travel Date & Time and rider details.

Points to Note

• The distance-between method can be used on two address fields with the following Deluge code:
1. zoho.map.distanceBetween(Starting_Point, Drop, "KILOMETRE");

Zoho CRM Training Programs

Learn how to use the best tools for sales force automation and better customer engagement from Zoho's implementation specialists.

Redefine the way you work
with Zoho Workplace

Zoho DataPrep Personalized Demo

If you'd like a personalized walk-through of our data preparation tool, please request a demo and we'll be happy to show you how to get the best out of Zoho DataPrep.

Create, share, and deliver

beautiful slides from anywhere.

Zoho Sign now offers specialized one-on-one training for both administrators and developers.

 Quick Links Workflow Automation Data Collection Web Forms Enterprise Begin Data Collection Interactive Forms Workplace Data Collection App Offline Forms Customer Service Accessible Forms Digital Forms Marketing Forms for Small Business HTML Forms Education Forms for Enterprise Contact Forms E-commerce Lead Generation Forms Healthcare Wordpress Forms Customer onboarding No Code Forms Construction Free Forms Travel Prefill Forms Non-Profit Intake Forms Legal Form Designer HR Card Forms Food Assign Forms Photography Translate Forms Electronic Forms Notification Emails for Forms Holiday Forms Form to PDF HIPAA Forms

Zoho Pagesense Resources

You are currently viewing the help pages of Qntrlâ€™s earlier version. Click here to view our latest versionâ€”Qntrl 3.0's help articles.

New to Zoho Survey?

Manage your brands on social media

Zoho Desk Resources

• Desk Community Learning Series

• Digest

• Functions

• Meetups

• Kbase

• Resources

• Glossary

• Desk Marketplace

• MVP Corner

• Word of the Day

Zoho Sheet Resources

New to Zoho Forms?

Zoho Forms Resources

communication with Zoho Mail

Mail on the move with
Zoho Mail mobile application

Stay on top of your schedule
at all times

Carry your calendar with you
Anytime, anywhere

Zoho Sign Resources

Sign, Paperless!

Sign and send business documents on the go!

Zoho SalesIQ Resources

Zoho DataPrep Resources

Zoho DataPrep Demo

Get a personalized demo or POC

Design. Discuss. Deliver.

Create visually engaging stories with Zoho Show.

• Related Articles

• Rent calculation based on multiple values selected by customers for events

Requirement Estimate rent for a property based on the date and time it is booked, as well as attendance numbers. Use Case A party hall of a hotel is being rented out. Here is the pricing structure of the hall: Day Base price (in USD) Standard guests ...
• Prefill content in a form based on another form

Requirement When one form is submitted with data, users are redirected to another form with pre-filled data from the previous form. Use Case An order management app contains two forms: one to store suppliers' details, and the other to store the ...
• Update an existing record using stateless forms

Requirement   Use details specified in a stateless form to modify records in the main form. Use Case   In an order management system, a customer has placed an order and wants to cancel it. The administrators allow for cancellation by accepting the ...
• Appointment Management with Dynamic Drop Down

Requirement   Allow patients to book appointments with their doctors. Use Case   A clinic wants to digitize its booking system. There are multiple specialists and different dates/times for appointments. Each appointment lasts for 30 minutes. There ...
• Open Form B based on field value in Form A

Requirement   Open another form based on the value entered in the first form. Use Case   A course - planning platform wants to design the learning plans based on the learner's current knowledge. If a learner is a working professional, one is asked to ...
Wherever you are is as good as

Resources

Videos

Watch comprehensive videos on features and other important topics that will help you master Zoho CRM.

eBooks

Download free eBooks and access a range of topics to get deeper insight on successfully using Zoho CRM.

Webinars

Sign up for our webinars and learn the Zoho CRM basics, from customization to sales force automation and more.

CRM Tips

Make the most of Zoho CRM with these useful tips.