Skip to main content

Bartec Collective - Get Collection Dates

#* What is it? This formula will return the next or previous collection date of a particular job type at the specified property, given a start and end date to search between.

Setup

The formula requires the following settings under Settings > Integrations > Bartec Collective > Settings to be set:

  • Garden Feature Name Match
  • Residual Waste Name Match
  • Recycling Name Match

The values entered into these settings must partially match the name of corresponding jobs as configured in Bartec Collective.

Inputs

This formula requires 6 inputs to be passed through to it:

  • UPRN of the property to check

    The mapped value must come from an address lookup question, using the property_identifier variable option.

  • start date (yyyy-mm-dd)

    Only collections on or after this date will be displayed.

  • end date (yyyy-mm-dd)

    Only collections on or before this date will be displayed.

  • the job type

    The formula will only consider collections that match the specified job type.

  • Same day cut-off time

    When a job in Bartec Collective falls on the current day, this setting can be used to configure the time at which this job is classed as a previous collection rather than a next collection.

    If Use job time from Bartec Collective is chosen, the current date is returned as the next collection until the current time is after the job's scheduled start time.

    If Specify manually is chosen, a time can be specified in format hh:mm. The current date is returned as the next collection until the current time is after this specified time.

  • the date to return

    This can be either the next collection after the current day, or the last one prior to the current day.

Return values

ValueDescription
A date, in format yyyy-mm-ddIf a suitable collection date is found
an empty stringIf there is no matching date, or 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

  1. 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 an empty string.

  2. A call is made to Jobs_Get passing in the UPRN, IncludeRelated flag = true, start date and end date, to return all jobs for the property within the time period.

  3. A filter is obtained by analysing the job type input. If this is either garden waste, residual or recycling, the corresponding value set in the Integrations > Bartec Collective > Settings page is used. If Other was chosen, the manually specified value is used as a filter.

  4. For all the jobs that are returned, the job name is lowercased and compared to the filter from step 3 (also lowercased). When a match is found, the scheduled start of the job is added to a list of possible dates.

  5. If the date to return input is set to Next date, any possible dates before the current date and time are disregarded. If the date to return input is set to Previous date, any possible dates after the current date and time are disregarded.

  6. If there are no possible dates, the formula returns an empty string.

  7. The possible dates are sorted into ascending order.

  8. If the date to return input is set to Next date, the first date in the list is returned. If the date to return input is set to Previous date, the last date in the list is returned.