Business Hours
Business Hours
The BusinessHours
selects an exit according to the current Time of Day, Day of Week and
Day of Year. It is one of the most complex operation structures in the Flow Editor.
The BusinessHours
operation must have at least one exit. The BusinessHours
operation is only
useful when it has more than one exit, although this is not enforced by the operation definition.
The default Time Zone is “Platform Local Time”.
Config Parameters
The BusinessHours
operation config
attributes are as follows.
Parameter | Type | Description |
---|---|---|
timezone
|
String |
The timezone specifies the name of an entry in the TIME_ZONE_GEOGRAPHY_SET geography set.
This value may be missing (or may be null ) in which case the system default local time zone
will be used.
|
holiday_set
|
String |
The holiday_set specifies the name of a (public or private) holiday set to use when matching
any holidays as part of this operation. This parameter must be present if the operation performs any holiday
matching.
|
default_exit_idx
|
Integer |
[Required] The default_exit_idx is the zero-based index into the exits Array
to determine which exit to follow if none of the configured rules match.
|
rules
|
Array of Object |
[Required] The rules Array must contain none or more Objects.
|
Config Rules
A BusinessHours
operation rules
Object takes one of the following forms.
Parameter | Type | Description |
---|---|---|
days
|
String |
One of any (matches all days),
mmdd (matches a calendar day or range of calendar days),
holiday_entry (matches one of the named holidays),
any_holiday (matches any holiday in the set), or
dow (matches a single day of week or range of days of week).
|
start_day
|
Integer |
This parameter is permitted and mandatory only when days = dow . It must be in the range 0
(Sunday) to 6 (Saturday). This is the last (inclusive) day of week that will be matched by this rule.
|
end_day
|
Integer |
This parameter is permitted and mandatory only when days = dow . It must be in the range 0
(Sunday) to 6 (Saturday). This is the first (inclusive) day of week that will be matched by this rule.
Note that end_day may wrap around and hence be less than start_day .
|
start_mmdd
|
String |
This parameter is permitted and mandatory only when days = mmdd . It must be in the range 0101
(January 1st) to 1231 (December 31st) and must specify a valid four-digit Month + Day of Month.
This is the first date (inclusive) of the date range that will be matched by this rule.
|
end_mmdd
|
String |
This parameter is permitted and mandatory only when days = mmdd . It must be in the range 0101
(January 1st) to 1231 (December 31st) and must specify a valid four-digit Month + Day of Month.
This is the last date (inclusive) of the date range that will be matched by this rule.
|
holiday_entries
|
String |
This parameter is permitted and mandatory only for days = holiday_entry , and specifies
the names of the system-configured named holidays (which may possibly be multi-day holidays) which
will match for this rule. These named holiday must exist within the holiday set indicated by
the holiday_set parameter in the config Object.
|
exit_idx
|
Integer |
The zero-based index number of the exit to follow if this rules matches. The exit_idx parameter
should only be present when Time of Day routing is absent for a rule. Every rule must specify
exactly one of exit_idx or in_hours_exit_idx .
|
in_hours_exit_idx
|
Integer |
The zero-based index number of the exit to follow if time-based matching is present for this rule,
if the day matches, and if the current time falls within the configured hours for the rule. This
parameter may and must be present if and only if exit_idx is not present.
|
out_of_hours_exit_idx
|
Integer |
The zero-based index number of the exit to follow if time-based matching is present for this rule,
if the day matches, and if the current time falls outside the configured hours for the rule. This
parameter is not mandatory, and may be present if and only if in_hours_exit_idx is present.
|
start_hhmm
|
String |
A string in the range 0000 to 2359 indicating the start of time of day matching period for this
rule (if one exists). This parameter is permitted and mandatory if and only if end_hhmm is also present.
|
end_hhmm
|
String |
A string in the range 0001 to 2400 indicating the end of time of day matching period for this
rule (if one exists). This parameter is permitted and mandatory if and only if start_hhmm is also present,
and it must be different from start_hhmm . If this value is less than start_hhmm then it represents a
wrap-around period which includes midnight.
|
Matching Date and Time
When determining if a rule matches, first check the “Day” part of the rule, as follows:
-
days
=any
: Always matches. -
days
=mmdd
,start_mmdd
= [MMDD],end_mmdd
= [MMDD]: Matches if the month/day is within the indicated range (inclusive). -
days
=dow
,start_day
= [0-6],end_day
= [0-6]: Matches if the current day of week number is within the indicated range (inclusive) where Sunday =0
, Saturday =6
. -
days
=holiday_entry
,holiday_entries
= [Array of Entry Names] orentry_ids
= [Array of Entry IDs]: Matches if the current day matches the named Holiday Entry. -
days
=any_holiday
: Matches if the current day matches any Holiday Entry in the configuredholiday_set
.
If day does not match, then proceed to the next rule (or use default_exit_idx
if no more rules remain).
If day matches, proceed to matching the current time according to the rule’s exit_idx
, start_hhmm
, end_hhmm
,
in_hours_exit_idx
, and out_of_hours_exit_idx
based on the following permitted time rule parameter combinations:
-
exit_idx
only: No checking on current time of day is required, the rule always matches any time of day. -
start_hhmm
,end_hhmm
, andin_hours_exit_idx
only: If the current time of day matches the indicated 24-hour clock HHMM range, then follow the in-hours exit index, otherwise this rule does not apply. -
start_hhmm
,end_hhmm
,in_hours_exit_idx
, andout_of_hours_exit_idx
all present: If the current time of day matches the indicated 24-hour clock HHMM range, then follow the in-hours exit index, otherwise follow the out-of-hours exit.
If no rule matches, then the exit indicated by default_exit_idx
will be taken.
Example Operation
Here is an example BusinessHours
operation in JSON representation.
{
"id": 5,
"type": "BusinessHours",
"base_node": 1,
"config": {
"holiday_set": "National Holidays",
"rules": [
{ "days": "holiday_entry", "holiday_entries": [ "Easter Weekend" ], "exit_idx": 1 },
{ "days": "mmdd", "start_mmdd": "0401", "end_mmdd": "0401",
"start_hhmm": "1200", "end_hhmm": "1500",
"in_hours_exit_idx": 0, "out_of_hours_exit_idx": 1
},
{ "days": "any_holiday", "exit_idx": 1 },
{ "days": "dow", "start_day": 1, "end_day": 5,
"start_hhmm": "0900", "end_hhmm": "1730",
"in_hours_exit_idx": 0, "out_of_hours_exit_idx": 1
},
{ "days": "any", "start_hhmm": "0600", "end_hhmm": "2400", "in_hours_exit_idx": 2 }
],
"default_exit_idx": 1
},
"exits": [ 4, 17, 33 ]
}
The rules will evaluate the current date and time in the following sequence. All Holidays are as defined in the Holiday Set named and are evaluated according to the server “local time zone”.
-
On . Follow exit
1
to operation17
. -
On April 1st. Follow exit
0
to operation4
between noon and 3pm, else exit1
to operation17
. -
On any holiday. Follow exit
1
to operation17
. -
On Monday to Friday. Fllow exit
0
to operation4
between 9am to 5:30pm, else exit1
to operation17
. -
Any other day between 6am and midnight. Follow exit
2
to operation33
. -
Otherwise follow default exit
1
to operation17
.
Exits
By convention, the first exit represents the processing for “Closed” hours, and the second exit
for “Open” hours, with any additional exits representing secondary/alternate Open Hours. However, this is
purely a convention, and the definition of the BusinessHours
operation does not rely on any
particular intepretation of exits.
Exit Index | Name | Description |
---|---|---|
0
|
Exit #1 |
[Required] This array entry must exist, even if it has a null value.
By convention this is used to represent "Closed" hours, and may be labelled as such in the GUI.
|
1
|
Exit #2 + | By convention, Exits 2 and subsequent are used to represent "Open" hours, and may be labelled as such in the GUI. |