Build a Flow to Trigger a Custom Function

Zoho Bookings custom functions are notoriously unreliable. (We hope we can update this in the future with better news) That being said, it’s better to trigger any necessary custom function using Zoho Flow and its connection to Zoho Bookings.

In this simple function, we trigger the update of a CRM Contact record based on an appointment being booked. See the sample code below:

string bookings_to_crm(string booking_ID)
{
bookingRequest = invokeurl
[
 url :"https://www.zohoapis.com/bookings/v1/json/getappointment?booking_id=" + booking_ID
 type :GET
 connection:"zohobookings"
];
// info bookingRequest;
bookingInfo = bookingRequest.get("response").get("returnvalue");
// --------------
// Now we can run our actions with the booking record we fetched
Email = bookingInfo.get("customer_email");
info Email;
Contact = zoho.crm.searchRecords("Contacts","(Email:equals:" + Email + ")").get(0);
// info Contact;
ContactID = Contact.get("id").toNumber();
bookingDate = bookingInfo.get("start_time");
service = bookingInfo.get("service_name");
staff = bookingInfo.get("staff_name");
TimeZone = "-07:00";
JustDate = bookingDate.getPrefix(" ").toDate().toString("yyyy-MM-dd");
// info JustDate;
JustTime = bookingDate.getSuffix(" ");
// info JustTime;
appointmentReformat = (JustDate + "T" + JustTime + TimeZone).remove(" ");
info appointmentReformat;
Cmap = Map();
Cmap.put("Booking_Date",appointmentReformat);
Cmap.put("Booking_Service",service);
UpdateContact = zoho.crm.updateRecord("Contacts",ContactID,Cmap);
info UpdateContact;
return "GOT IT";
}
Back to Lesson