For Zoho services only


I'm currently part of a wider delivery team at Ascent Business Solutions, recognised as a leading Zoho Premium Solutions Partner in the United Kingdom.

Ascent Business Solutions support organisations with everything from targeted technical fixes through to full Zoho CRM implementations and long-term platform adoption. Working as a team rather than a one-person consultancy allows projects to move forward consistently, with access to the right skills at each stage.

The team I manage specialises in API integrations between Zoho and third-party finance and commerce platforms such as Xero, Shopify, WooCommerce, and eBay. Much of our work involves solving integration challenges that fall outside standard documentation, supporting new ideas, new sectors, and evolving business models.

Success is measured through practical outcomes and return on investment, ranging from scaling small operations into high-turnover businesses to delivering rapid gains through online payments, automation, and streamlined digital workflows.

If you are looking for structured Zoho expertise backed by an established consultancy, you can contact Ascent Business Solutions on 0121 392 8140 (UK), email info@ascentbusiness.co.uk, or visit https://www.ascentbusiness.co.uk.
Zoho Deluge: Zoho Bookings Get Available Slots

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 Deluge :: Article: 286

Accreditation

Badge - Zoho Creator Certified Developer Associate
Badge - Zoho Deluge Certified Developer
Badge - Certified Zoho CRM Developer

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

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