Bartec Collective - Can Report Missed Collection
- What is it? This formula will verify if a missed collection report can be made against a property by checking if the property if registered for assisted collection and then by checking if any jobs are recorded against the property within the last 2 days.
Setup
The formula requires the Assisted Collection Description under Settings > Integrations > Bartec Collective > Settings to be set. The value entered into the setting must match the description of the attribute as configured in Bartec Collective.
Inputs
This formula requires 1 input 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 property_identifier variable option.
Return values
Value | Description |
---|---|
Yes | If its possible to report a missed collection for the property |
No | If there is already a service request open for a missed collection at the property |
error | If there is an error when trying to query Bartec Collective via the API. |
Note: return values are case sensitive
Caching
When using 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 error.
-
A call is made to Premises_Attributes_Get passing in the UPRN input which returns all the attributes set on a property
-
If no attributes are returned from the API the formula will return error
-
For all the attributes that are returned, the attribute description is lowercased and compared to Assisted Collection Description value from the settings (also lowercased). When a match is found the formula will return Yes, indicating that the property is registered for assisted collection and therefore can report a missed collection.
-
A call is made to Jobs_Get passing in the UPRN input, IncludeRelated flag = true and calculated start and end dates.
Start Date: If the current time is before 16:00 the start date is set to the previous day, if the current time is equal to or after 16:00 the start date is set to the current day.
End Date: The end date is the start date plus 1 day.
If there is an error connecting to the Bartec API the formula will return error at this point.
-
If any jobs are returned by the call to Jobs_Get the formula will return Yes otherwise the formula returns No.