Calendar and booking / Booking forms
Randomizing resource weights in booking forms
Published 28. sep. 2026, 16.03
TL;DR
Get resources with bookingForm.getCalendarResources() , assign a random number (e.g. 10-50) to each resource.weight , then apply with bookingForm.setCalendarResources(resources) . Place the script in an HTML component so it can be reused across forms.
Booking forms use resource weights to decide which available time slots to suggest first. By randomizing these weights you spread bookings more evenly across all eligible resources - no single person always gets the first spot.
Get started in 3 steps
- Open the booking form. Go to Styling → Custom JavaScript or create/edit an HTML component attached to the form.
- Paste the script below. It fetches all resources, assigns a random weight between 10 and 50, then pushes the updated values back. In Styling → Custom JavaScript, leave out the
<script>tags.<script> var resources = bookingForm.getCalendarResources(); var min = 10; var max = 50; for (var i = 0; i < resources.length; i++) { resources[i].weight = Math.floor(Math.random() * (max - min + 1)) + min; } bookingForm.setCalendarResources(resources); </script> - Save the form and test on the public URL. Refresh several times and confirm that different resources appear first in the suggested slots.
Read more
How it works
bookingForm.getCalendarResources()returns the resources configured in the form.- A random weight (10-50) is assigned per resource on each page load - so every visitor can get a different suggested order.
- Higher weight = higher suggestion priority.
bookingForm.setCalendarResources(resources)applies the new weights before time slots are calculated.
Best practices
- Keep the weight range narrow (e.g. 10-50) to avoid extreme bias.
- Test with realistic resource availability and transit settings.
- Document the script location so other admins can find and maintain it.
- Prefer placing in an HTML component for reuse across multiple booking forms.
Troubleshooting
If results do not change across refreshes, verify that: (1) the script runs before suggestions are generated, (2) all expected resources are included in the booking form's resource setup, and (3) there is no other weight-setting script overriding these values after the fact.
resource
weight
random
Didn't find the answer? Submit a ticket and we'll get back to you as soon as possible.