Forum Discussion
Optional parameter of function is making "null" as a parameter
- 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,
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
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,
- Anonymous6 years agoNot applicable
I just tried and it works fine.
My project is a little different, as it doesn't prompt the user before the navigation table shows up though.
It's a function that may or may not have one of those params. The default result shows up immediately before any user input.