Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Power Apps Pro Dev & ISV
Unanswered

Creating Power App^2 Developer Tools and generating PowerFX from JSON

(0) ShareShare
ReportReport
Posted on by 486

I'm trying to facilitate power apps development in the grey area between professional and non-professional (aka citizen) software developers. I want to create tools that may help both types of developers creating and using PCF components or more complex traditional components, and I believe it is important that I actually use Power Platform to achieve it.

I've often encountered a need to generate Power FX code, E.g. for static menu galleries or settings for various components etc. Even though ParseJSON() and JSON() are useful in many ways, there seems to be a barrier for exporting PowerFX object notation such as the code for a table or object in an app to the user. (Essentially just removing the double quotes from field names) 

I have arrived at a hack and I'm wondering if I'm missing some essential trick for this, I am interested to hear about other methods to achieve this or similar things.

One example is a configuration tool for the Creator Kit DetailsList control that takes a collection for format configuration. 

hjaf_0-1693242686234.png

 

Getting the JSON is simple, but translating this object into a PowerFX object notation is convoluted, the following is the formula for the Refresh buttons (lower right) OnSelect property:

 

With(
 {
 JsonPayload: JSON(
 colDetailsListColumns,
 JSONFormat.IndentFour
 )
 },
 Clear(colJsonPayloadTable);
 ForAll(
 Split(
 JsonPayload,
 ""
 ),
 Collect(
 colJsonPayloadTable,
 {
 CharNo: CountRows(colJsonPayloadTable),
 Char: ThisRecord
 }
 )
 );
 ForAll(
 MatchAll(
 JsonPayload,
 "(\"")([a-zA-Z]+)(\"":)"
 ) As JsonFormatFieldName,
 RemoveIf(
 colJsonPayloadTable,
 CharNo = JsonFormatFieldName.StartMatch - 1// Relative position of the first double quote.
 );
 RemoveIf(
 colJsonPayloadTable,
 CharNo = JsonFormatFieldName.StartMatch + Len(JsonFormatFieldName.FullMatch) - 3// relative position of the second double quote
 )
 );
 UpdateContext(
 {
 locDetailsListConfigurationJson: JsonPayload,
 locDetailsListConfigurationPfx: Concat(
 colJsonPayloadTable,
 Char.Value,
 ""
 )
 }
 );
 Clear(colJsonPayloadTable)
);

 

This works perfectly for basic objects, but I suspect its not supporting complex objects and I believe its going to stall for slightly bigger objects.

I've tried other ways of using MatchAll() and Substitute() / Replace() but, I find it very difficult to debug and keep track of escaping the double quotes etc. Anyone else worked on something similar and have some suggestions on how this can be done differently? 

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

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Congratulations to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Power Apps - Power Apps Pro Dev & ISV

#1
WarrenBelz Profile Picture

WarrenBelz 85 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 65 Super User 2025 Season 1

#3
mmbr1606 Profile Picture

mmbr1606 55 Super User 2025 Season 1

Overall leaderboard