For Zoho Services only:


I'm actually part of something bigger at Ascent Business Solutions recognized as the top Zoho Premium Solutions Partner in the United Kingdom.

Ascent Business Solutions offer support for smaller technical fixes and projects for larger developments, such as migrating to a ZohoCRM.  A team rather than a one-man-band is always available to ensure seamless progress and address any concerns. You'll find our competitive support rates with flexible, no-expiration bundles at https://ascentbusiness.co.uk/zoho-services/uk-zoho-support.  For larger projects, talk to our experts and receive dedicated support from our hands-on project consultants at https://ascentbusiness.co.uk/zoho-services/zoho-crm-implementation.

The team I manage specializes in coding API integrations between Zoho and third-party finance/commerce suites such as Xero, Shopify, WooCommerce, and eBay; to name but a few.  Our passion lies in creating innovative solutions where others have fallen short as well as working with new businesses, new sectors, and new ideas.  Our success is measured by the growth and ROI we deliver for clients, such as transforming a garden shed hobby into a 250k monthly turnover operation or generating a +60% return in just three days after launch through online payments and a streamlined e-commerce solution, replacing a paper-based system.

If you're looking for a partner who can help you drive growth and success, we'd love to work with you.  You can reach out to us on 0121 392 8140 (UK) or info@ascentbusiness.co.uk.  You can also visit our website at https://ascentbusiness.co.uk.

Zoho Deluge: Zoho Bookings Get Available Slots

What?
This is an article of code snippets to query a Zoho Bookings instance from within Creator. This one focuses on getting the available slots.

Why?
This is for a Creator app which had a form to allow customers to make a booking based on the configuration and appointments in a ZohoBookings instance.

How?
The getAvailableSlots function requires as parameters according to documentation
<response> = zoho.bookings.getAvailableSlots(<service_id>, <staff_id>, <date>, <connection>);

Set up your connector with the following scope:
copyraw
zohobookings.data.CREATE
  1.  zohobookings.data.CREATE 

Get the workspaces:
copyraw
//
// get workspaces
r_WorkspaceResults = zoho.bookings.getWorkspaces("joels_connector");
l_Workspaces = r_WorkspaceResults.get("response").get("returnvalue").get("data");
for each  r_Workspace in l_Workspaces
{
	if(!isnull(r_Workspace.get("id")))
	{
		v_WorkspaceName = r_Workspace.get("name");
	}
}
  1.  // 
  2.  // get workspaces 
  3.  r_WorkspaceResults = zoho.bookings.getWorkspaces("joels_connector")
  4.  l_Workspaces = r_WorkspaceResults.get("response").get("returnvalue").get("data")
  5.  for each  r_Workspace in l_Workspaces 
  6.  { 
  7.      if(!isnull(r_Workspace.get("id"))) 
  8.      { 
  9.          v_WorkspaceName = r_Workspace.get("name")
  10.      } 
  11.  } 

Get the services:
copyraw
//
// get services
r_ServiceResults = zoho.bookings.getRelatedRecords("Services","Workspaces",v_WorkspaceID,"joels_connector");
l_Services = r_ServiceResults.get("response").get("returnvalue").get("data");
for each  r_Service in l_Services
{
	if(!isnull(r_Service.get("id")))
	{
		v_ServiceName = r_Service.get("name");
	}
}
  1.  // 
  2.  // get services 
  3.  r_ServiceResults = zoho.bookings.getRelatedRecords("Services","Workspaces",v_WorkspaceID,"joels_connector")
  4.  l_Services = r_ServiceResults.get("response").get("returnvalue").get("data")
  5.  for each  r_Service in l_Services 
  6.  { 
  7.      if(!isnull(r_Service.get("id"))) 
  8.      { 
  9.          v_ServiceName = r_Service.get("name")
  10.      } 
  11.  } 

Get the staff:
copyraw
//
// get staff
r_StaffResults = zoho.bookings.getRelatedRecords("Staffs","Services",v_ServiceID,"joels_connector");
l_Staff = r_StaffResults.get("response").get("returnvalue").get("data");
for each  r_Staff in l_Staff
{
	if(!isnull(r_Staff.get("id")))
	{
		v_StaffName = r_Staff.get("name");
	}
}
  1.  // 
  2.  // get staff 
  3.  r_StaffResults = zoho.bookings.getRelatedRecords("Staffs","Services",v_ServiceID,"joels_connector")
  4.  l_Staff = r_StaffResults.get("response").get("returnvalue").get("data")
  5.  for each  r_Staff in l_Staff 
  6.  { 
  7.      if(!isnull(r_Staff.get("id"))) 
  8.      { 
  9.          v_StaffName = r_Staff.get("name")
  10.      } 
  11.  } 

Get the Available slots:
copyraw
//
// get available slots
r_AvailableSlots = zoho.bookings.getAvailableSlots(v_ServiceID,v_StaffID,v_ThisDate.toString("dd-MM-yyyy"),"joels_connector");
l_AvailableSlots = r_AvailableSlots.get("response").get("returnvalue").get("data");
if(!l_AvailableSlots.toString().containsIgnoreCase("Slots Not Available"))
{
	for each  r_AvailableSlot in l_AvailableSlots
	{
		if(!r_AvailableSlot.contains("00:00") && !isNull(r_AvailableSlot))
		{
			v_HourCheck = r_AvailableSlot.getPrefix(":").toLong();
			if(v_HourCheck < 12)
			{
				input.Morning:ui.add(r_AvailableSlot);
				v_CountMorning = v_CountMorning + 1;
				v_CountTotal = v_CountTotal + 1;
			}
			else if(v_HourCheck >= 12 && v_HourCheck < 16)
			{
				input.Afternoon:ui.add(r_AvailableSlot);
				v_CountAfternoon = v_CountAfternoon + 1;
				v_CountTotal = v_CountTotal + 1;
			}
			else if(v_HourCheck >= 16 && v_HourCheck < 20)
			{
				input.Evening:ui.add(r_AvailableSlot);
				v_CountEvening = v_CountEvening + 1;
				v_CountTotal = v_CountTotal + 1;
			}
			else
			{
				input.Night:ui.add(r_AvailableSlot);
				v_CountNight = v_CountNight + 1;
				v_CountTotal = v_CountTotal + 1;
			}
		}
	}
}
  1.  // 
  2.  // get available slots 
  3.  r_AvailableSlots = zoho.bookings.getAvailableSlots(v_ServiceID,v_StaffID,v_ThisDate.toString("dd-MM-yyyy"),"joels_connector")
  4.  l_AvailableSlots = r_AvailableSlots.get("response").get("returnvalue").get("data")
  5.  if(!l_AvailableSlots.toString().containsIgnoreCase("Slots Not Available")) 
  6.  { 
  7.      for each  r_AvailableSlot in l_AvailableSlots 
  8.      { 
  9.          if(!r_AvailableSlot.contains("00:00") && !isNull(r_AvailableSlot)) 
  10.          { 
  11.              v_HourCheck = r_AvailableSlot.getPrefix(":").toLong()
  12.              if(v_HourCheck < 12) 
  13.              { 
  14.                  input.Morning:ui.add(r_AvailableSlot)
  15.                  v_CountMorning = v_CountMorning + 1
  16.                  v_CountTotal = v_CountTotal + 1
  17.              } 
  18.              else if(v_HourCheck >= 12 && v_HourCheck < 16) 
  19.              { 
  20.                  input.Afternoon:ui.add(r_AvailableSlot)
  21.                  v_CountAfternoon = v_CountAfternoon + 1
  22.                  v_CountTotal = v_CountTotal + 1
  23.              } 
  24.              else if(v_HourCheck >= 16 && v_HourCheck < 20) 
  25.              { 
  26.                  input.Evening:ui.add(r_AvailableSlot)
  27.                  v_CountEvening = v_CountEvening + 1
  28.                  v_CountTotal = v_CountTotal + 1
  29.              } 
  30.              else 
  31.              { 
  32.                  input.Night:ui.add(r_AvailableSlot)
  33.                  v_CountNight = v_CountNight + 1
  34.                  v_CountTotal = v_CountTotal + 1
  35.              } 
  36.          } 
  37.      } 
  38.  } 
Done.

Notes:
  1. You need the workspaces to get the services.
  2. You need the services to get the staff.
  3. You need the staff and service to get the available slots.

Source(s):
Category: Zoho :: Article: 749

Credit where Credit is Due:


Feel free to copy, redistribute and share this information. All that we ask is that you attribute credit and possibly even a link back to this website as it really helps in our search engine rankings.

Disclaimer: Please note that the information provided on this website is intended for informational purposes only and does not represent a warranty. The opinions expressed are those of the author only. We recommend testing any solutions in a development environment before implementing them in production. The articles are based on our good faith efforts and were current at the time of writing, reflecting our practical experience in a commercial setting.

Thank you for visiting and, as always, we hope this website was of some use to you!

Kind Regards,

Joel Lipman
www.joellipman.com

Related Articles

Joes Revolver Map

Accreditation

Badge - Certified Zoho Creator Associate
Badge - Certified Zoho Creator Associate

Donate & Support

If you like my content, and would like to support this sharing site, feel free to donate using a method below:

Paypal:
Donate to Joel Lipman via PayPal

Bitcoin:
Donate to Joel Lipman with Bitcoin bc1qf6elrdxc968h0k673l2djc9wrpazhqtxw8qqp4

Ethereum:
Donate to Joel Lipman with Ethereum 0xb038962F3809b425D661EF5D22294Cf45E02FebF
© 2024 Joel Lipman .com. All Rights Reserved.