Hello,
I'm using Power fx in PAD but working with data tables seems so much harder than the old syntax in PAD.
I have a some text that is actually JSON, then I'm using a convert JSON to custom object to convert it into an object I can work with. But even after reading the documentation on powerfx about untyped objects - I can't figure out how to insert the values from the custom object (TmpEventList) into data table (EventsTable) so it only has the actual value in the data table rows & columns and not some custom object representation.
This is the JSON text variable TmpEventsOut:
[
{
"Title": "Test Europe 2025",
"Position": 0
},
{
"Title": "Test Europe 2024",
"Position": 1
},
{
"Title": "Test Spring 2025",
"Position": 2
}
]
The events table definition is this where Position (from JSON) would be mapped to Position, and Title (from JSON) would be mapped to Event:
All the for each loop is doing is iterating through the List and trying to insert each item as row in the data table, but I can't get it to work ☹️
I put in an intermediate step to create a row record in variable NewVar which looks like this:
={Position:Value(CurrentItem.Position), Event: Text(CurrentItem.Title)}
But when I try and insert that into the datatable EventsTable it gives me the following error:
Correlation Id: 21efddb0-f7d1-4e1c-a584-2578cb219764
Microsoft.PowerPlatform.PowerAutomate.Desktop.Actions.SDK.ActionException: The amount of values provided to be added (1) don't match the columns of the data table (2).
at Microsoft.Flow.RPA.Desktop.Modules.Variables.Actions.AddRowToDataTable.Execute(ActionContext context)
at Microsoft.Flow.RPA.Desktop.Robin.Engine.Execution.ActionRunner.Run(IActionStatement statement, Dictionary`2 inputArguments, Dictionary`2 outputArguments)
Don't understand why is not working, also is there an easier way to insert values in a datatable based on column position instead of defining every column with a name and value before inserting into the table?