Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.
Hello,
I'm having trouble finding what's wrong when invoking a custom function from another.
Consider:
/* getTimeEntryPage(updateFrom, page) */
(updateFrom as text, page as text) =>
let
...
in
...
This works as expected whan manually invoked with, for example: getTimeEntryPage("2021-03-24", "1").
Now, I also have this:
/* getTimeEntriesFromDate(updateFrom) */
(updateFrom as text) =>
let
Source = Json.Document(Web.Contents(/*This query works*/)),
List = {1..Source[total_pages]},
#"Converted to Table" = Table.FromList(List, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
#"Changed Type" = Table.TransformColumnTypes(#"Converted to Table",{{"Column1", type text}}),
#"Renamed Columns" = Table.RenameColumns(#"Changed Type",{{"Column1", "page"}}),
#"Invoked Custom Function" = Table.AddColumn(#"Renamed Columns", "getTimeEntryPage", each getTimeEntryPage(updateFrom, [page])),
...
in
...
When I call getTimeEntriesFromDate("2021-03-24") manually, I get the following error:
"Unexpected error: Operation is not valid due to the current state of the object."
In the #"Invoked Custom Function" line, the following will work (although will only return a subset of data):
getTimeEntryPage(updateFrom, "1")
In the same line, the following will return the same error as above (expected as 1 is a number, not the expected text type):
getTimeEntryPage(updateFrom, 1)
Since [page] is set to text type, I don't understand why this is not working. Does anyone have an idea?
Note: I've made sure the origin data is clean.
Thanks!
Solved! Go to Solution.
Hi @golbarg
Are you sure it is the issue with [page]? Can you try to wrap Text.From([page]), see how it goes?
#"Invoked Custom Function" = Table.AddColumn(#"Renamed Columns", "getTimeEntryPage", each getTimeEntryPage(updateFrom, Text.From([page])))
Hi @golbarg
Are you sure it is the issue with [page]? Can you try to wrap Text.From([page]), see how it goes?
#"Invoked Custom Function" = Table.AddColumn(#"Renamed Columns", "getTimeEntryPage", each getTimeEntryPage(updateFrom, Text.From([page])))
Hey @Vera_33,
Wow, that was easier than expected, it worked, thanks!
Any idea why I need to convert a text value to text? It feels wrong.
Hi @golbarg
No, it does not seem to be needed to convert a text to text...I tried to replicate your case with a simple custom function and a list of numbers, it worked after the column changed to text, did not occur the issue...maybe you should have a look at your custom function getTimeEntryPage