Date-range request filters
Select a boundary contract first
Use request-level date filters when a service accepts explicit time bounds and the connector needs to limit what it retrieves. Keep this separate from pagination: a date window selects the logical data interval, while page state traverses the rows returned for that interval. The two examples below disagree on omitted bounds, so copying a signature alone is insufficient.13
A connector function accepting RangeStart and RangeEnd is not by itself proof of a correctly configured incremental-refresh policy. Microsoft's incremental refresh configuration also describes model parameters, filtering, and policy configuration. This page studies request construction in the archive, not a tested service refresh deployment.
InformationGrid: both bounds or an unbounded request
InformationGridImpl obtains a service list and chooses GetIncrementalRefreshServiceData for entries with non-empty parameter lists. That factory returns a function with two optional nullable datetime arguments. The returned function closes over the base URL, service name, and credential-bearing options record.41
If either argument is null, the function builds a request without either range parameter. If both are supplied, it formats them as text and appends a literal Z, then supplies them to BuildRequestUrl. That helper merges the range record with biClient and biClientVersion and encodes the resulting query with Uri.BuildQueryString. The factory does not compare start and end or perform a timezone conversion before adding that suffix.15
SolarWinds: reject invalid pairs, default missing values
ContentsV110 and ContentsV113 forward arguments to NavigationV. Its first guard rejects a supplied pair with RangeStart >= RangeEnd; the next uses Duration.Days(RangeEnd - RangeStart) > 365*2. Both require non-null arguments. The unversioned Contents instead calls the beta entry point, bypassing these guards. The implementation defaults a missing start to one month before local DateTime.LocalNow() and a missing end to that value, formats both using a resource string, and forwards them to paging.23
| Input case | InformationGrid | SolarWinds |
|---|---|---|
| Both null | Omits both bounds. | Uses a rolling default window. |
| One bound supplied | Omits both bounds. | Defaults the missing bound separately. |
| Equal or reversed supplied bounds | No local order check in the factory. | Raises the invalid-range error before navigation construction. |
| Both valid | Serializes both into query parameters. | Formats both, then hands them to paging. |
The table describes these functions' local decisions, not the servers' interpretation of timestamp boundaries.123
Adaptation and failure checks
Choose and test null behavior explicitly. A partially supplied range should not silently become a full-history request unless that is your intended API contract. Decide which timezone the input represents before formatting it; appending Z does not add a conversion step to this source. Verify with the service whether the upper bound is inclusive or exclusive, and test adjacent windows for gaps and duplicates.1
SolarWinds already passes its chosen bounds unchanged across pages. GetQuery sends them as updated_custom_gte and updated_custom_lt; confirm the service's interpretation of those names. Preserve that consistency when adapting paging. Inspect the localized date format before copying the defaults; the resource value is not retained here, so the final zone representation is unknown.63
Examples
A factory that closes over request context
This complete InformationGrid factory shows both null handling and request construction. BuildRequestUrl and GetServiceData remain dependencies in the surrounding file.1
InformationGrid/InformationGrid.pq · lines 71–87 Open original source ↗
GetIncrementalRefreshServiceData = (baseUrl as text, serviceName as text, options as record) as function =>
(optional RangeStart as nullable datetime, optional RangeEnd as nullable datetime) as table =>
let
// Build URL with range parameters if provided
url = if (RangeStart = null or RangeEnd = null) then
BuildRequestUrl(baseUrl, "retrieve/" & serviceName)
else
let
// Convert datetime to ISO-8601 format
rangeStartStr = DateTime.ToText(RangeStart, "yyyy-MM-ddTHH:mm:ss") & "Z",
rangeEndStr = DateTime.ToText(RangeEnd, "yyyy-MM-ddTHH:mm:ss") & "Z"
in
BuildRequestUrl(baseUrl, "retrieve/" & serviceName, [RangeStart = rangeStartStr, RangeEnd = rangeEndStr]),
result = GetServiceData(url, options)
in
result;
Validate a supplied pair before building navigation
SolarWinds' complete navigation function gives the guard conditions a clear position before request dispatch.2
SolarwindsServiceDesk/SolarWindsServiceDesk.pq · lines 32–56 Open original source ↗
SolarWindsServiceDesk.NavigationV = (version as text, optional RangeStart as datetime, optional RangeEnd as datetime, optional CustomFieldsStr as text) =>
if (RangeStart <> null and RangeEnd <> null and RangeStart >= RangeEnd) then error Extension.LoadString("ErrorInvalidRange")
else if (RangeStart <> null and RangeEnd <> null and Duration.Days(RangeEnd - RangeStart) > 365*2) then error Extension.LoadString("ErrorLimitRangeMessage") // 2 years limit
else
let
objects = #table({"Name", "Data", "ItemKind", "ItemName", "IsLeaf"}, {
{ "Incidents", SolarWindsServiceDeskImpl(version, "incidents", RangeStart, RangeEnd, CustomFieldsStr), "Table", "Table", true }
}),
assets = #table({"Name", "Data", "ItemKind", "ItemName", "IsLeaf"}, {
{ "Hardwares", SolarWindsServiceDeskImpl(version, "hardwares", RangeStart, RangeEnd, CustomFieldsStr), "Table", "Table", true },
{ "Softwares", SolarWindsServiceDeskImpl(version, "softwares", RangeStart, RangeEnd, CustomFieldsStr), "Table", "Table", true },
{ "Mobiles", SolarWindsServiceDeskImpl(version, "mobiles", RangeStart, RangeEnd, CustomFieldsStr), "Table", "Table", true },
{ "Printers", SolarWindsServiceDeskImpl(version, "printers", RangeStart, RangeEnd, CustomFieldsStr), "Table", "Table", true },
{ "Network Devices", SolarWindsServiceDeskImpl(version, "discovery_hardwares", RangeStart, RangeEnd, CustomFieldsStr), "Table", "Table", true },
{ "Other Assets", SolarWindsServiceDeskImpl(version, "other_assets", RangeStart, RangeEnd, CustomFieldsStr), "Table", "Table", true }
}),
objectsFolder = Table.ToNavigationTable(objects, {"Name"}, "Name", "Data", "ItemKind", "ItemName", "IsLeaf"),
assetsFolder = Table.ToNavigationTable(assets, {"Name"}, "Name", "Data", "ItemKind", "ItemName", "IsLeaf"),
source = #table({"Name", "Data", "ItemKind", "ItemName", "IsLeaf"}, {
{ "All Objects", objectsFolder, "Folder", "Folder", false },
{ "Assets", assetsFolder, "Folder", "Folder", false }
}),
navTable = Table.ToNavigationTable(source, {"Name"}, "Name", "Data", "ItemKind", "ItemName", "IsLeaf")
in
navTable;
Defaults belong to the consumer
This complete implementation shows what happens when only one bound is supplied, which the preceding guards do not reject.3
SolarwindsServiceDesk/SolarWindsServiceDesk.pq · lines 58–68 Open original source ↗
SolarWindsServiceDeskImpl = (version as text, dataType as text, optional RangeStart as datetime, optional RangeEnd as datetime, optional CustomFieldsStr as text) as table =>
let
today = DateTime.LocalNow(),
startDate = if RangeStart = null then DateTime.ToText(Date.AddMonths(today, -1), Extension.LoadString("DateFormat")) else DateTime.ToText(RangeStart, Extension.LoadString("DateFormat")),
endDate = if RangeEnd = null then DateTime.ToText(today, Extension.LoadString("DateFormat")) else DateTime.ToText(RangeEnd, Extension.LoadString("DateFormat")),
tracedStartDate = Diagnostics.Trace(TraceLevel.Information, GetTraceData(version, dataType, startDate, endDate), () => startDate, true),
// make sure customFieldsNames is a list - empty or not - but not an option List
customFieldsNames = if CustomFieldsStr <> null and CustomFieldsStr <> "" then List.Transform(Text.Split(CustomFieldsStr, ","), each Text.Trim(_)) else {},
rows = GetAllPagesByNextLink(version, tracedStartDate, endDate, dataType, customFieldsNames)
in
rows;
See web requests and function parameters.
-
InformationGrid optional date-bound factory and serialization. ↩↩↩↩↩↩
-
SolarWinds pair validation and versioned navigation dispatch. ↩↩↩
-
InformationGrid chooses the factory using service-list parameter presence. ↩
-
InformationGrid merges client metadata and encodes range query parameters. ↩
-
SolarWinds preserves the bounds through its paging callback and constructs the date query fields. ↩