In this Power Apps Dataverse Tutorial, I will show you how to fix an error, The JSON function cannot serialize tables / objects with a nested property called ‘_ownerid_value’ of type ‘Polymorphic’ that comes while working with the Power Apps JSON function.
When I was working with Power Apps recently, I had to use the JSON function to get the names of the columns in the dataverse table.
I got a polymorphic error when attempting to use the Power Apps JSON function.
The screenshot below represents the error that displays: The JSON function cannot serialize tables / objects with a nested property called ‘_ownerid_value’ of type ‘Polymorphic’.
Now we’ll go into more detail regarding this issue and how to resolve it.
Also, Read: How to get Collection Column Names in Power Apps [From 3 Different Datasources]
The JSON function cannot serialize tables / objects with a nested property called ‘_ownerid_value’ of type ‘Polymorphic’ – Error
- Here, I have a Dataverse Table named Car Booking Details. This table has various columns and as well as records as shown below.
- Car Name, Booking Date, Buyer Name, and Buyer Contact Number are my Dataverse table columns.
- Now I wanted to retrieve all the Dataverse table columns in Power Apps. In order to fulfill this requirement, I first established a Power Apps Collection and added all the Dataverse columns to it. [All the below codes I have written on the Button’s OnSelect property]
ClearCollect(
colCarBookingInfo,
'Car Booking Details'
);
Where,
- colCarBookingInfo = Collection name
- ‘Car Booking Details‘ = Dataverse table name
- I then used the code below, where I had to use the Power Apps JSON function, to extract all of the collection column headings.
Set(
varColumnNames,
Distinct(
Ungroup(
MatchAll(
JSON(
colCarBookingInfo,
JSONFormat.IgnoreBinaryData
),
"([^""]+?)""\s*:"
).SubMatches,
"SubMatches"
),
Value
)
)
Where,
- varColumnNames = Variable name where the result will store
- colCarBookingInfo = Collection name that you have created
- While I used the JSON function and added the collection name to it, I got an error like “The JSON function cannot serialize tables / objects with a nested property called ‘_ownerid_value’ of type ‘Polymorphic’.“
- The error states clearly that lookup fields like ownerid and primarycontactid cannot be serialized. There is a JSON format value to include Unsupported types, therefore it’s all ok. But how do you define it? We have previously specified IgnoreBinaryData, after all.
In the below section, we will see how we can fix this above issue in Power Apps JSON function.
The JSON function cannot serialize tables / objects with a nested property called ‘_ownerid_value’ of type ‘Polymorphic’ – Solution
When I ran across this issue, I did some online research and visited a number of websites. However, I came up with a solution and added it to the code. I then resolved my problem and continued the process as needed.
It’s a simple trick, though. To combine the two formats, all you need to do is use the “&” operator; in fact, you can use as many as you like. And also, you need to use the JSONFormat.IgnoreUnsupportedTypes function.
Refer to the solution code below as well:
Set(
varColumnNames,
Distinct(
Ungroup(
MatchAll(
JSON(
colCarBookingInfo,
JSONFormat.IgnoreBinaryData & JSONFormat.IgnoreUnsupportedTypes
),
"([^""]+?)""\s*:"
).SubMatches,
"SubMatches"
),
Value
)
)
Where,
JSONFormat.IgnoreUnsupportedTypes = Unsupported data types are accepted, but they won’t be included in the final result.
Simply Save, Publish, and Test the app after entering the above formula. And now it functions wonderfully.
This is how we can solve the Power Apps JSON function error i.e. The JSON function cannot serialize tables / objects with a nested property called ‘_ownerid_value’ of type ‘Polymorphic’.
Furthermore, you may like some more Power Apps & Dataverse tutorials:
- Invalid Connection. Please Choose a Connection Power Automate
- How To Remove Commas From Dataverse Number Field
- How to Update a Row in Dataverse Using Power Automate
- How to Detect Text in Dataverse Using AI Builder
- The function Search has some invalid arguments in PowerApps
- You don’t have permission to view this data error in PowerApps
- How To Get Dataverse List Rows Count Using Power Automate
In this Power Apps Dataverse Tutorial, We discussed how to solve the error, The JSON function cannot serialize tables / objects with a nested property called ‘_ownerid_value’ of type ‘Polymorphic’ that comes while working with the Power Apps JSON function.
I am Bijay a Microsoft MVP (10 times – My MVP Profile) in SharePoint and have more than 17 years of expertise in SharePoint Online Office 365, SharePoint subscription edition, and SharePoint 2019/2016/2013. Currently working in my own venture TSInfo Technologies a SharePoint development, consulting, and training company. I also run the popular SharePoint website EnjoySharePoint.com