Forum Discussion

tcollett0's avatar
tcollett0
Frequent Visitor
1 year ago
Solved

Dataflow Gen2 - Getting source name

Now to Dataflow Gen2 and Power Query:   I have a list of sources (individual databases in Business Central) and from there I want to pull data from each source (which I can do).  Here is a sample l...
  • v-karpurapud's avatar
    v-karpurapud
    1 year ago

    Hi tcollett0 

    To achieve this, define a variable to store the source name string before navigation steps, and then add it as a custom column after loading the target table. Adjust existing code as follows:

    let

      Source = Dynamics365BusinessCentral.ApiContentsWithOptions("CityWide-UAT", null, null, [UseReadOnlyReplica = true, AcceptLanguage = null, Timeout = null, ODataMaxPageSize = null]),

      SourceName = "Central Kentucky",

      Navigation1 = try Source{[Name = SourceName]}[Data] otherwise error "Source '" & SourceName & "' not found",

      Navigation2 = try Navigation1{[Name = "WebServices"]}[Data] otherwise error "WebServices not found",

      Navigation3 = try Navigation2{[Name = "CW_G_L_Entries", Signature = "table"]}[Data] otherwise error "CW_G_L_Entries not found",

      AddSourceColumn = Table.AddColumn(Navigation3, "Source_Location", each SourceName, type text)

    in

      AddSourceColumn

    This ensures that each row in your final result will carry the correct source name without hardcoding it multiple times.

    If this post helps, kindly mark it Accepted Solution. It will helps others to find more easily.

    Thank You!