Randomizing Resource Weights in Booking Forms
Hubhus booking forms let you control how resources are prioritized when suggesting times. This article explains how to randomize weights to distribute bookings more evenly.
How to randomize resource weights in a booking form
Use this approach when multiple resources can handle the same booking and you want fairer distribution instead of repeatedly prioritizing the same person.
Recommended: place the script in an HTML component so it is easier to maintain and reuse across booking forms.
Example: Assign random weights to all bookable resources
<script>
// Generate a random weight for a resource
function getRandomWeight(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
// Get the currently available calendar resources
var resources = bookingForm.getCalendarResources();
var resourceKeys = Object.keys(resources);
// Assign a random weight (10-50) to each resource
resourceKeys.forEach(function(resourceKey) {
resources[resourceKey].weight = getRandomWeight(10, 50);
});
// Apply the updated weights
bookingForm.setCalendarResources(resources);
</script>How it works
bookingForm.getCalendarResources()retrieves the resources selected in the form.- A random weight between 10 and 50 is generated for each resource.
- Higher weight means higher priority in suggestion logic.
- Updated values are applied with
bookingForm.setCalendarResources(resources).
This runs when the form loads, so each visitor can get a different resource priority order.
When to use this
- When you want to avoid repeatedly suggesting the same resource.
- When all resources are equally suitable for the job.
- When you want a simple rotation-like distribution without hardcoding fixed priorities.
Quick setup
- Open the relevant booking form.
- Add the script in your HTML component or script area.
- Save the form and test on the public URL.
- Confirm that different resources are prioritized across tests.
Best practices
- Keep weight range narrow enough to avoid extreme bias.
- Test with realistic resource availability and transit settings.
- Document the script location so other admins can maintain it.
Troubleshooting
If results do not change, verify that the script runs before suggestions are generated and that all expected resources are included in the booking form resource setup.
Summary
Randomizing resource weights helps distribute bookings more fairly when several resources can handle the same appointment. The script-based setup is simple, reusable, and works well for balanced load distribution in booking forms.
Common searches
random resource weight, booking form resource priority, fair resource distribution, booking rotation, bookingform weights
Also known as
resource weighting, random resource selection, booking resource balancing, resource priority randomization
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