Forum Discussion

mbowler's avatar
mbowler
Helper I
1 year ago
Solved

Scheduled refresh on Web.Contents that has calculated date parameter

I've read a few posts where people have a similar problem but I can't see an obvious solution.

 

The problem I have is that I need to use a web query to access audit data from our Dynamics 365 system (audit data is not available via Dataverse api), however as there are millions of records I want to just the last months records. The query below works in the PB Desktop and can be manually refreshed on the service but I need this to refresh daily but I'm seeing this error on the service:

 

The query is this:

let
#"Today" = DateTime.LocalNow(),
#"Today Minus 1 Month" = Date.AddMonths(DateTime.Date(#"Today"),-1),
#"FormattedDate" = Date.ToText(#"Today Minus 1 Month", [Format="yyyy-MM-dd"]),
#"WebQuery" = "https://orgname.crm4.dynamics.com/api/data/v9.2/audits?" & "$select=_objectid_value,objecttypecode,createdon,_userid_value&$orderby=createdon desc" & "&$filter=objecttypecode eq 'myobjectname' and createdon gt " & #"FormattedDate",
Source = Json.Document(Web.Contents(#"WebQuery", [Headers=[Accept="application/json", Prefer="odata.include-annotations=""*"""]])),


 

All help gratefully appreciated.

3 Replies