Forum Discussion

mike_asplin's avatar
mike_asplin
Helper V
4 months ago
Solved

Bit of help to identifying a dynamic data source

Hi. I have a modle that pulls some of its data form Microsoft Dynmics. Some very helpful people guided me how to create a url that pulled in specific column and dates rather than pulling whole thing ...
  • vojtechsima's avatar
    vojtechsima
    4 months ago

    Hey, mike_asplin ,

    basically in your case, you can jsut do this:

    let
        BaseUrl = "https://chxxxxd.api.crm11.dynamics.com",
        Endpoint = "api/data/v9.1/bookableresourcebookings",
        
        SelectColumns = "bookableresourcebookingid,_bookingstatus_value,_resource_value,name,_cha_clientid_value,_owningteam_value,duration,starttime,_cha_carercontactid_value,_msdyn_workorder_value,msdyn_totalcost,endtime,statuscode,msdyn_milestraveled,msdyn_actualarrivaltime",
        
        FilterDateText = DateTime.ToText(#"Load Date", "yyyy-MM-ddTHH:mm:ssZ"),
        
        QueryRecord = [
            #"$select" = SelectColumns,
            #"$filter" = "starttime ge " & FilterDateText
        ],
        
        Source = Json.Document(Web.Contents(
            BaseUrl, 
            [
                RelativePath = Endpoint,
                Query = QueryRecord
            ]
        )),
        
        Data = Source[value]
    in
        Data

    The most important part, and what causes the Dynamic Source flag, is the splitting the host and relative path:

    BaseUrl = "https://chxxxxd.api.crm11.dynamics.com",
    Endpoint = "api/data/v9.1/bookableresourcebookings",