Forum Discussion
Custom data connector (SDK) help required
Are you saying that you want to populate a navigation table with a list of databases and, under each database, a list of tables and have it look something like what is described here in the multi-level navigation table section?
https://docs.microsoft.com/en-us/power-query/handlingnavigationtables
Chris
Hi Chris,
Thank you very much for your response, Yes, exactly, multi-level or nested navigation, I have tried using the hard-coded sample then changed the code to bring databases dynamically in the name part as below, i have tried to create a sample code for what I required, not sure how to loop through each table to pass its name and get the tables relevant to it:
shared NavigationTable.Nested = (url) as table => let objects
= #table( {"Name", "Key", "Data", "ItemKind", "ItemName", "IsLeaf"},
{ {GetDatabaseName(url), "n1", NavTable(url), "Database", "Database", false}
}), NavTable = Table.ToNavigationTable(objects, {"Key"}, "Name", "Data", "ItemKind", "ItemName", "IsLeaf") in NavTable;
GetDatabaseName= (url as text) as table =>
let
Source = DataConnector_3.Feed(url & "GetDatabases"),
json = Json.Document(Source,1252),
MyJsonTable= Table.FromRecords(json),
#"Removed Other Columns" = Table.SelectColumns(MyJsonTable,{"DBName"})
in
#"Removed Other Columns";
NavTable = (url as text) as table =>
let
source = #table({"Name", "Data", "ItemKind", "ItemName", "IsLeaf"}, {
{ "Table1", GetTable1(url), "Table", "Table", true}
}),
navTable = Table.ToNavigationTable(source, {"Name"}, "Name", "Data", "ItemKind", "ItemName", "IsLeaf")
in
navTable;
GetTable1 = (url as text,dbname as text) as table =>
let
Source = DataConnector.Feed(url & "GetTable1",dbname),
json = Json.Document(Source,1252),
MyJsonTable= Table.FromRecords(json)
in
MyJsonTable;
DataConnector.Feed = (url as text, optional dbname as text) =>
let
Credential = Extension.CurrentCredential(),
split=Text.Split(Credential[Username],"#"),
source = Web.Contents(url, [ Headers = DefaultRequestHeaders, ManualCredentials = true, Query = [
user_key = split, db_name=dbname]]),
json = Json.Document(source)
in
json;
I am not sure, how to itterate the "NavigationTable.Nested" function for each database for which the db name would be pass to CreateNavTable funtion.
I have searched internet and still un-able to find any sample which helps me create dynamic navigation.
Do you know any sample available for dynamic navigation? Would be really helpful.
Kind regards,
- Anuj66 years agoFrequent Visitor
Hi,
Were you able to find the solution to this problem, i am also trying to do something like this in my custom connector.
Thanks
- Jeanesh6 years agoNew MemberHi,
Rather than build a connector in the power query SDK why not build it outside in the cloud?
My course teaches you exactly how to do this and goes through detailed walkthroughs and everything I do is done without writing any code!
https://businessautomator.co.uk/no-code-business-intelligence-connector-development/