Randomizing Resource Weights in Booking Forms

Modified on Tue, 5 May at 11:24 AM

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

1

Open the booking form. Go to Styling → Custom JavaScript or create/edit an HTML component attached to the form.

2

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);
3

Save the form and test on the public URL. Refresh several times and confirm that different resources appear first in the suggested slots.

When to use: multiple equally qualified resources  ·  Avoid: when you need fixed priority rules or tier-based routing
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

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article