Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Optional parameter of function is making "null" as a parameter

Hey guys, I've built a custom connector and I decided to change the parameter of a function in the Navigator to a dropdown list. For that, I had to provide function documentation, and since the para...
  • v-lid-msft's avatar
    6 years ago

    Hi Anonymous ,

     

    Based on my test, it will show a blank rows on my side if no value provided. Sorry for that, but it seems not supported to remove the blank rows from dropdown list.

     

    All the code we tested with are  here,the code were modified from the sample customer connector

     

    section HelloWorldWithDocs;
    
    [DataSource.Kind="HelloWorldWithDocs", Publish="HelloWorldWithDocs.Publish"]
    shared HelloWorldWithDocs.Contents = Value.ReplaceType(HelloWorldImpl, HelloWorldType);
    
    shared Params2 = type text meta [
            Documentation.FieldCaption = "Count",
            Documentation.FieldDescription = "Number of times to repeat the message",
            Documentation.AllowedValues = { "1", "2", "3" }
        ];
    
    HelloWorldType = type function (
        message as (type text meta [
            Documentation.FieldCaption = "Message",
            Documentation.FieldDescription = "Text to display",
            Documentation.SampleValues = {"Hello world", "Hola mundo"}
        ]),
        optional count as (Params2)
        )
        as table meta [
            Documentation.Name = "Hello - Name",
            Documentation.LongDescription = "Hello - Long Description",
            Documentation.Examples = {[
                Description = "Returns a table with 'Hello world' repeated 2 times",
                Code = "HelloWorldWithDocs.Contents(""Hello world"", 2)",
                Result = "#table({""Column1""}, {{""Hello world""}, {""Hello world""}})"
            ],[
                Description = "Another example, new message, new count!",
                Code = "HelloWorldWithDocs.Contents(""Goodbye"", 1)",
                Result = "#table({""Column1""}, {{""Goodbye""}})"
            ]}
        ];
    
    HelloWorldImpl = (message as text, optional count as text) as table =>
        let
            _count = if (count <> null) then count else "5",
            listOfMessages = List.Repeat({message}, Value.FromText(_count) as number),
            table = Table.FromList(listOfMessages, Splitter.SplitByNothing())
        in
            table;
    
    // Data Source Kind description
    HelloWorldWithDocs = [
        Authentication = [
            Anonymous = []
        ]//,
        //Label = "Hello World With Docs"
    ];
    
    // Data Source UI publishing description
    HelloWorldWithDocs.Publish = [
        Beta = true,
        Category = "Other",
        ButtonText = { "Hello World With Docs", "Provides an example of how to provide function documentation" }
    ];
    


    Best regards,