Quantcast
Channel: Developer topics
Viewing all articles
Browse latest Browse all 18035

Custom Data Connector UI - Dropdown list

$
0
0

I am creating a custom data connector for PowerBI and want to display a drop-down list in the UI, So I am using file.Contents(localpath) function to get the list of values. While using file.Contents(local path) function in .pq file , I am getting the following error.. 

custom connector.png  code : 

 

section HelloWorld;

[DataSource.Kind="HelloWorld", Publish="HelloWorld.Publish"]
shared HelloWorld.Contents = Value.ReplaceType(HelloWorldImpl, HelloWorldType);

HelloWorldType = type function (
    message as (type text meta [
        Documentation.FieldCaption = "Message",
        Documentation.FieldDescription = "Text to display",
        Documentation.SampleValues = {"Hello world", "Hola mundo"}
    ]),
    name as (type text meta [
        Documentation.FieldCaption = "Names",
        Documentation.AllowedValues = ListOfNames //{ "1", "2", "3" }
    ]))
   as table meta [
        Documentation.Name = "Hello - Name",
        Documentation.LongDescription = "Hello - Long Description",
        Documentation.Examples = {[
            Description = "Another example, new message, new count!",
            Code = "HelloWorldWithDocs.Contents(""Goodbye"", 1)",
            Result = "#table({""Column1""}, {{""Goodbye""}})"
        ]}
    ];

HelloWorldImpl = (message as text, name as text) as table =>
    let
       listOfMessages = List.Repeat({message & name},5),
       table = Table.FromList(listOfMessages, Splitter.SplitByNothing())
    in
        table;

 Names =
        let
            Source = Csv.Document(File.Contents("F:\temp\ListofNames.txt"),[Columns=1, Encoding=1252, QuoteStyle=QuoteStyle.None]),
            GetTable = Table.TransformColumnTypes(Source,{{"Column1", type text}}),
            FilterTable = Table.SelectRows(GetTable, each Text.StartsWith([Column1], "[") and Text.EndsWith([Column1], "]"))
        in
            FilterTable;
               
ListOfNames = Table.ToList(Names);

HelloWorld = [
    Authentication = [
        Anonymous = []
    ],
    Label = Extension.LoadString("DataSourceLabel")
];

HelloWorld.Publish = [
    Beta = true,
    ButtonText = { Extension.LoadString("FormulaTitle"), Extension.LoadString("FormulaHelp") },
    SourceImage = HelloWorld.Icons,
    SourceTypeImage = HelloWorld.Icons
];

HelloWorld.Icons = [
    Icon16 = { Extension.Contents("HelloWorld16.png"), Extension.Contents("HelloWorld20.png"), Extension.Contents("HelloWorld24.png"), Extension.Contents("HelloWorld32.png") },
    Icon32 = { Extension.Contents("HelloWorld32.png"), Extension.Contents("HelloWorld40.png"), Extension.Contents("HelloWorld48.png"), Extension.Contents("HelloWorld64.png") }
];

 

 

Note: The ListofNames, I am getting the values from .txt file. If I hardcode the values {"1","2","3"} it works fine.

Documentation.AllowedValues = ListOfNames //{ "1", "2", "3" }

 

 


Viewing all articles
Browse latest Browse all 18035

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>