Forum Discussion
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 parameter for the function has to be optional (I don't want it to be passed to Top Level Navigation function), it generated a "null" option:
It doesn't cause any errors because it is handled, but I'd like it to disappear. How do I do that without removing "optional"?
Params = type text
meta [Documentation.Description = "Please select a time range",
Documentation.FieldCaption = "Time Range (Default is medium):",
Documentation.AllowedValues = {"Short (4 weeks)","Medium (6 months)","Long (Overall)"}];
Function1Type = type function(
optional time_range as Params)
as table;
[DataSource.Kind="Project1"]
shared Project1.Function1 = (optional Params) => Value.ReplaceType(Function1, Function1Type);
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,
4 Replies
- v-lid-msft
Community Support
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,- AnonymousNot applicable
I see, thank you for the help.
Do you have any clue why you have a blank value but I have a null instead?
Best Regards,
CAOP- v-lid-msft
Community Support
Hi Anonymous ,
Could you please try to run the sample code(Hello World with Docs) which is in the document and see what will show? Since Our modified code is very similar as yours, so the problem might be something outside the code.
Best regards,