Occupancy Rules

When Conflict Rules are enabled, GoMeddo calculates occupancy with Occupancy Rules. They decide which time counts as closed and how occupied the open time is. GoMeddo creates default rules that give the same results as before, so your occupancy charts keep working without any setup. You can change them to, for example, count a room with half its beds booked as 50% occupied.

Before you start: Occupancy Rules are available from GoMeddo 7.7 and only apply when Use the Conflict Rules engine is enabled. Without Conflict Rules, occupancy works as before. You need the B25 Admin permission set to create or edit rules. See Conflict Rules for the formula language.

How occupancy is calculated

Occupancy splits time into closed time and open time, and then works out how much of the open time is occupied. Each dimension (such as Resource or Staff) uses 2 Occupancy Rules:

Occupancy Role

Formula returns

Meaning

Closed

True or false

True when the time is closed. Closed time doesn't count toward occupancy.

Occupied

A number from 0 to 100

How much of the open time is occupied, as a percentage.

GoMeddo runs the rules for every stretch of time in the period, adds up the closed, open, and occupied minutes, and shows the occupied percentage as occupied minutes divided by open minutes. For example, if the Occupied rule returns 50 for 2 open hours, that's 1 occupied hour.

Like Conflict Rules, Occupancy Rules are phrased as the problem: a Closed rule says when time is closed, not when it's open.

Default rules

When you install or upgrade GoMeddo, it creates these active rules for the Resource and Staff dimensions:

Developer Name

Occupancy Role

What it does

RESOURCE_OCCUPANCY_CLOSED
STAFF_OCCUPANCY_CLOSED

Closed

Time without availability is closed: IsNotAvailable().

RESOURCE_OCCUPANCY_OCCUPIED
STAFF_OCCUPANCY_OCCUPIED

Occupied

Open time is fully occupied (100) when a booking exists whose status doesn't allow double booking, and free (0) otherwise. For resources, it also skips resource types that allow double bookings.

The default Occupied formula for resources:

IF(B25__Resource__r.B25__Resource_Type__r.B25__AllowDoubleBookings__c != true
    AND B25__Status__r.B25__AllowDoubleBooking__c != true
    AND COUNT(FILTER(overlappingReservations AS rsv, rsv.B25__Status__r.B25__AllowDoubleBooking__c != true)) > 0,
    100, 0)

You can't edit or delete the default rules. You can deactivate them. To change one, clone it, edit the clone, and deactivate the original. GoMeddo doesn't recreate a default rule you deactivated.

Create an Occupancy Rule

  1. Go to the GoMeddo Rules tab.

  2. Click New.

  3. Select the Occupancy Rule record type and click Next.

  4. Enter a GoMeddo Rule Name and a unique Developer Name.

  5. Select the Dimension, for example Resource.

  6. Select the Occupancy Role: Closed or Occupied.

  7. Enter the Formula and click Check Syntax.

  8. Keep Is Active selected.

  9. Click Save.


A Closed formula must return true or false, and an Occupied formula must return a number. GoMeddo checks this when you save. Occupancy Rules never block or warn about reservations: they're only used for occupancy.

When you add a second active rule with the same role on the same dimension, deactivate the one you replace, or select the rule to use (see Choose which rule to use). Otherwise occupancy shows an error.

Example: occupancy based on capacity

The default rules count a resource as fully occupied as soon as it has a booking. For resources that take several people, such as a dormitory with 8 beds, you can count occupancy by capacity instead: 4 beds booked shows as 50%.

Clone RESOURCE_OCCUPANCY_OCCUPIED, replace the formula with this one, and deactivate the original:

IF(B25__Resource__r.B25__Capacity__c > 0,
    SUM(FILTER(overlappingReservations AS rsv, rsv.B25__Status__r.B25__AllowDoubleBooking__c != true), B25__Quantity__c, 1)
        / B25__Resource__r.B25__Capacity__c * 100,
    0)

The formula adds up the quantity of the overlapping bookings (counting a booking without a quantity as 1) and divides it by the resource's capacity. The IF keeps resources without a capacity at 0, so the formula never divides by zero.

Write your own formulas

Occupancy Rules use the same formula language as Conflict Rules, including overlappingReservations, matchingAvailabilities, and IsNotAvailable(). Keep these points in mind:

  • GoMeddo evaluates the formula for a placeholder reservation on the dimension record. It only has a start, an end, and the dimension record (for example B25__Resource__c). Its other fields, such as B25__Quantity__c and B25__Status__c, are empty. To look at the actual bookings, use overlappingReservations.

  • Fields of the dimension record work as usual, for example B25__Resource__r.B25__Capacity__c.

  • Soft and hard conflicts don't exist for Occupancy Rules. To leave out bookings that may overlap, filter them in the formula, as the default rule does with B25__AllowDoubleBooking__c.

  • An Occupied value below 0 counts as 0 and a value above 100 counts as 100. When that happens, the occupancy chart's tooltip says "A rule returned a value outside 0-100 in this period. It was limited to that range." A value above 100 usually means the period is overbooked.

  • Return a percentage, not a fraction. A formula that returns 0.5 for half occupied shows as 0.5%.

  • If the formula fails while it runs, for example by dividing by zero, occupancy shows "Occupancy Rule <name> could not be evaluated for record <id>: <error>".

Don't use $Permission in an Occupancy Rule unless you want occupancy to differ per user. For example, if you copy $Permission.ALLOW_DOUBLE_BOOKING != true from a Conflict Rule, users with that permission see 0% occupied.

Choose which rule to use

By default, GoMeddo uses the only active rule with each role on the dimension. To use a specific rule instead, for example to show capacity-based occupancy on one page and the default on another, select it where you show occupancy:

  • Occupancy component: in Lightning App Builder, select the rules in Closed Occupancy Rule and Occupied Occupancy Rule.

  • Get Occupancy data Flow action and Apex: set closedRuleDeveloperName and occupiedRuleDeveloperName to the rules' developer names. See Get Occupancy data.

Leave a field empty to use the only active rule with that role. A selected rule must be an active Occupancy Rule with the right role on the same dimension.

How GoMeddo picks the rules:

Situation

Result

One active rule with the role on the dimension

GoMeddo uses it.

More than one, and none selected

Error: "More than one active Occupied Occupancy Rule exists for B25__Resource__c: <names>. Select the rule to use."

No active Closed rule

All time counts as open.

No active Occupied rule, but there is an active Closed rule

Error: "No active Occupied Occupancy Rule exists for B25__Resource__c."

No active Occupancy Rules at all on the dimension, and none selected

GoMeddo calculates occupancy the old way, as without Conflict Rules. This applies to custom dimensions, which get no default rules.

What changes when you switch to Conflict Rules

  • A period without any open time shows as 0% occupied. Before, it showed as 100%. For example, a resource without availability records is closed all the time with the default rules, so it now shows 0% instead of 100%.

  • Periods follow each resource's time zone, so a day with a daylight saving time change has 23 or 25 hours.

  • As before, occupancy only counts the reservations the user can see.