Skip to main content

Notifications

Power Automate - Power Automate Desktop
Suggested answer

Powerfx converting custom objects to datatable

(2) ShareShare
ReportReport
Posted on by 16
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?
Categories:
  • Suggested answer
    Deenuji_Loganathan_ Profile Picture
    Deenuji_Loganathan_ 6,087 on at
    Powerfx converting custom objects to datatable
    Hi,
     

    Power Fx for Power Automate Desktop is still in preview and has many limitations. If you create your bot with the Power Fx enabled feature, there is a high risk if Microsoft makes changes during the General Availability (GA) release. Therefore, we do not recommend using Power Fx for any flows at this time.

     

    Please let me know your thoughts.

     

    Thanks,

    Deenu

     
     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Microsoft Kickstarter Events…

Register for Microsoft Kickstarter Events…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 145,636

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,942

Leaderboard