Specify more than one JSONFormat value inside JSON function in canvas app

Follow my blog for more interesting topics on Dynamics 365, Portals and Power Platform. For training and consulting, write to us at info@xrmforyou.com
This one is a really simple trick which is required in so many. How can I specify multiple JSONFormat values inside JSON() function in canvas app?


Before I go ahead and provide an answer to it, it’s important to understand the scenarios when you need to specify multiple JSON formats. There can be so many situations but I can give you a real life example that we were trying to achieve.
We were trying to serialize CDS entity data into JSON variable. So basically it was the Accounts entity data. We wanted to serialize the data into JSON but not include the Image data types. So basically we need to exclude Binary data (for image fields). Well it was simple. Below is the formula we wrote. But to no luck.
image
We got an error – “The JSON function cannot serialize tables / objects with a nested property called ‘_ownerid_value’ of type ‘Polymorphic’”.
The error clearly states that it is not able to serialize the lookup fields like ownerid, primarycontactid etc. That’s fine, there is a JSON format value to include Unsupported types. But how to specify it. After all we have already specified IgnoreBinaryData.
Well it’s an easy trick. All you need to do is use the ‘&’ operator to concatenate the two formats and in-fact you can use as many you want.
image
And now it works like a charm.
Hope this helps!
Debajit Dutta
(Business Solution MVP)