Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
namratapawale
Frequent Visitor

Enter function parameter values in between function calls in custom data connector during execution

Hi all,

I have a use case where I want to ask user to enter the data source name (existing power BI provided data sources) to connect to and then subsequently retrieve the input values for that data source in another function call and so on process that data further using custom logic ( like mask sensitive information) .. 

For example:

 

 

// This file contains your Data Connector logic
section SampleConnector;

[DataSource.Kind="SampleConnector", Publish="SampleConnector.Publish"]
shared SampleConnector.Contents = (DataSourceName as text) as any =>
let
Source = if (DataSourceName = "HDFS") then
SampleConnector.HDFS()
else
"Unknown"
in
Source;

[DataSource.Kind="SampleConnector", Publish="SampleConnector.Publish2"]
shared SampleConnector.HDFS= (ServerName as text) as any =>
let
Files = Hdfs.Files(ServerName)
in
Files;

....... more functions.....

 

Is there a way to achieve this?

 

 

2 REPLIES 2
v-jiascu-msft
Employee
Employee

Hi @namratapawale,

 

We can write several functions like below. Then we can call them. But it seems the data sources are limited for now. Please refer to docs/m-extensions.md#data-source-functions.

// This file contains your Data Connector logic
section PQExtension1;

[DataSource.Kind="PQExtension1", Publish="PQExtension1.Publish"]
shared PQExtension1.Contents = (which as text, url as text, path as text) =>
    let
        result = if (which = "web") then get_from_web(path) else get_from_odata(url)
    in
        result;

Headers=[#"Content-type" = "application/x-www-form-urlencoded",#"Accept" = "application/json"];

get_from_odata = (url as text) => 
	let 
		Source = OData.Feed(url)
	in
		Source;

get_from_web = (path as text) =>
	let 
		content = Web.Contents(path, [Headers = Headers]),
                json = Json.Document(content)
        in
        json;


// Data Source Kind description
PQExtension1 = [
    Authentication = [
        Key = [],
        UsernamePassword = [],
        Windows = [],
        Implicit = []
    ],
    Label = Extension.LoadString("DataSourceLabel")
];

// Data Source UI publishing description
PQExtension1.Publish = [
    Beta = true,
    Category = "Other",
    ButtonText = { Extension.LoadString("ButtonTitle"), Extension.LoadString("ButtonHelp") },
    LearnMoreUrl = "https://powerbi.microsoft.com/",
    SourceImage = PQExtension1.Icons,
    SourceTypeImage = PQExtension1.Icons
];

PQExtension1.Icons = [
    Icon16 = { Extension.Contents("PQExtension116.png"), Extension.Contents("PQExtension120.png"), Extension.Contents("PQExtension124.png"), Extension.Contents("PQExtension132.png") },
    Icon32 = { Extension.Contents("PQExtension132.png"), Extension.Contents("PQExtension140.png"), Extension.Contents("PQExtension148.png"), Extension.Contents("PQExtension164.png") }
];

 

Best Regards,

Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @v-jiascu-msft

Thanks for the reply! 

In the example that you've given you're taking parameters that are required by both the connectors right? 

So incase i wanted to allow 5 data sources which in this case are ODBC data sources (as it can be extensible), will the connector UI make fields appear and disappear based on the input provided? It is possible to have multiple UI's for a connector, such as a next button that'll display the the next set of parameters based on the first input?

 

Regards,

Namrata.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.