The JSON function cannot serialize tables / objects with a nested property called ‘{Attachments}’ of type ‘Table(Attachment)’ Power Apps

In this Power Apps Tutorial, I will show you how to fix an error, The JSON function cannot serialize tables / objects with a nested property called ‘{Attachments}’ of type ‘Table(Attachment)’ that comes while working with the Power Apps JSON function.

I recently had to use the JSON function when working with Power Apps to retrieve all the column names from the SharePoint list.

I got a nested property Attachments 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 ‘{Attachments}’ of type ‘Table(Attachment)’.

The JSON function cannot serialize tables objects with a nested property called '{Attachments}' of type 'Table(Attachment)' Power Apps
The JSON function cannot serialize tables objects with a nested property called ‘{Attachments}’ of type ‘Table(Attachment)’ Power Apps

We’ll now go into more depth about this problem and how to fix it.

Also, Read: The JSON function cannot serialize tables / objects with a nested property called ‘_ownerid_value’ of type ‘Polymorphic’ Power Apps

The JSON function cannot serialize tables / objects with a nested property called ‘{Attachments}’ of type ‘Table(Attachment)’ – Error

  • Here, I have an Employee Onboarding SharePoint List. As shown below, this list includes several columns as well as records.
  • ID, Employee Name, Employee Last Name, Employee ID, etc are my SharePoint list column names.
SharePoint list
SharePoint list
  • Now, I wanted Power Apps to retrieve every SharePoint list column. I first created a Power Apps Collection and stored all the SharePoint list columns in it in order to satisfy this need. [I have written all the codes below on the Button’s OnSelect property]
ClearCollect(
    colEmpOnboardingDetails,
    'Employee Onboarding'
);

Where,

  1. colEmpOnboardingDetails = Collection Name
  2. Employee Onboarding‘ = SharePoint List Name
  • I then extracted all of the collection column headings using the code below, where I had to use the Power Apps JSON function.
Set(
    varListColumnNames,
    Distinct(
        Ungroup(
            MatchAll(
                JSON(
                    colEmpOnboardingDetails,
                    JSONFormat.IgnoreBinaryData
                ),
                "([^""]+?)""\s*:"
            ).SubMatches,
            "SubMatches"
        ),
        Value
    )
)

Where,

  1. varListColumnNames = Variable name where the result will store
  2. colEmpOnboardingDetails = 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 ‘{Attachments}’ of type ‘Table(Attachment)’.
  • The error states clearly that the fields like Attachments of ‘Table(Attachment)’ cannot be serialized. It’s all fine because there is a JSON format value to include Unsupported kinds. But what does it mean exactly? After all, we have specified IgnoreBinaryData.
The JSON function cannot serialize tables objects with a nested property called '{Attachments}' of type 'Table(Attachment)'
The JSON function cannot serialize tables objects with a nested property called ‘{Attachments}’ of type ‘Table(Attachment)’

In the below section, we will see how we can fix this above issue in Power Apps JSON function.

See also  PowerApps Functions Tutorial

The JSON function cannot serialize tables / objects with a nested property called ‘{Attachments}’ of type ‘Table(Attachment)’ – Solution

When I encountered this problem, I went some online research and looked at a variety of websites. But I found a workaround and applied it to the code. I subsequently found a solution to my issue and continued on as necessary.

But it’s only a tiny trick. You only need to use the “&” operator to combine two formats, and you can use as many as you wish. You must use the JSONFormat. IgnoreUnsupportedTypes function as well.

The json function cannot serialize tables attachments
The JSON function cannot serialize tables attachments

You can refer to the solution code below as well:

Set(
    varListColumnNames,
    Distinct(
        Ungroup(
            MatchAll(
                JSON(
                    colEmpOnboardingDetails,
                    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.

Enter the formula above, then Save, Publish, and Test the app. And it now works flawlessly.

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 ‘{Attachments}’ of type ‘Table(Attachment)’.

Additionally, you may like some more Power Apps & Dataverse tutorials:

In this Power Apps Tutorial, We discussed how to solve the error, The JSON function cannot serialize tables / objects with a nested property called ‘{Attachments}’ of type ‘Table(Attachment)’ that comes while working with the Power Apps JSON function.

>