Bartec Collective - Future Workpacks
- What is it? This formula will return a list of all possible workpacks within a date range where it is possible to add a Service Request relating to a particular property and task. This formula is designed to be used as an input to the Bartec - Date Selector integrated component, to offer customers the ability to choose a date for a particular waste related task at their property.
Inputs
This formula requires 9 inputs to be passed through to it:
-
the UPRN of the property to check open service requests against.
The mapped value must come from an address lookup question, using the propery_identifier variable option.
-
the feature type
This input has a set of options to choose from, which is populated by a call to Feature_Types_Get.
-
the feature status (optional)
This input has a set of options to choose from, which is populated by a call to Feature_Statuses_Get. If it is not necessary to filter by status, choose All Statuses.
-
the booking period in weeks
This input expects a numerical value, which can be entered by typing in the dropdown and pressing the return key.
-
the booking cut-off in hours
This input expects a numerical value, which can be entered by typing in the dropdown and pressing the return key.
-
the maximum number of jobs allowed per workpack (Optional)
This input expects a numerical value, which can be entered by typing in the dropdown and pressing the return key.
-
the maximum number of premises allowed per workpack (Optional)
This input expects a numerical value, which can be entered by typing in the dropdown and pressing the return key.
-
the maximum job weight allowed per workpack (Optional)
This input expects a numerical value, which can be entered by typing in the dropdown and pressing the return key.
-
the maximum job volume allowed per workpack (Optional)
This input expects a numerical value, which can be entered by typing in the dropdown and pressing the return key.
Return values
Value | Description |
---|---|
A JSON-encoded list of available workpacks | If there is one or more available date, the return value is a list of available dates, with associated workpack IDs |
'No available booking dates' | If there are no available dates, or an error occurred. |
Note: Return values are case sensitive
Caching
When setting up this formula the calls to the Bartec Collective API are cached for the time specified in Settings > Integrations > Bartec Collective > Settings under the Cache Timeout setting.
Setting the Cache Timeout to 0 Minutes/Hours will disable caching on this formula.
Formula Logic
-
A check is made to see if the integration has been enabled in the Settings > Integrations page. If the integration is not enabled the formula returns No available booking dates.
-
The start of the booking period is calculated, by taking the current date/time, and adding (24 + the number of hours specified as the cut-off period). The booking period begins at midnight on this date.
As an example, if the current time is 7pm on Wednesday and the cut-off period is 4 hours, the booking period starts at midnight on Thursday, as Wednesday 7pm + 28 hours is 11pm on Thursday. If the current time is 9pm on Wednesday, the booking period starts at midnight on Friday, as Wednesday 9pm + 28 hours is 1am on Friday.
-
The end of the booking period is calculated, by taking the next day's date, and adding the number of weeks specified by the booking period input.
-
A call is made to Premises_FutureWorkPacks_Get passing in the UPRN, feature status, feature type and booking period inputs. This returns matching workpacks.
-
If no workpacks are returned from the API the formula will return No available booking dates.
-
For all the workpacks that are returned, the workpack values are tested against the corresponding maximum values provided as inputs:
- JobsCount must be less than
maximum number of jobs allowed per workpack
- PremisesCount must be less than
maximum number of premises allowed per workpack
- JobsVolume must be less than
maximum job volume allowed per workpack
- JobsWeight must be less than
maximum job weight allowed per workpack
If all the above conditions are satisfied, the workpack is added to the list of dates to be output.
Optional inputsAll maximum values are optional. If one is left unset, the corresponding workpack value will not be checked.
If all maximum values are left unset, all matching workpacks for the property are returned.
- JobsCount must be less than
-
The output is JSON-encoded and returned.