Randomizing resource weights in booking 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.
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.
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:
function getRandomWeight(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
var resources = bookingForm.getCalendarResources();
var resourceKeys = Object.keys(resources);
resourceKeys.forEach(function(key) {
resources[key].weight = getRandomWeight(10, 50);
});
bookingForm.setCalendarResources(resources);
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.
Common searches
random resource weight • booking form resource priority • fair resource distribution • booking rotation • bookingform weights • getCalendarResources
Was this article helpful?
That’s Great!
Thank you for your feedback
Sorry! We couldn't be helpful
Thank you for your feedback
Feedback sent
We appreciate your effort and will try to fix the article