#PowerPlatformTip 80: 'Rapid Dynamic Forms with AI'
TL;DR: Render forms dynamically by binding a Power Apps gallery to a JSON array, let AI generate the schema so fields adapt on the fly without static form controls.
💡 Challenge
Creating dynamic forms in Power Apps can be time-consuming, especially when Microsoft Forms doesn’t meet your needs due to its limitations on dynamic content. Additionally, using a Form Control for manual static data like a JSON array is not feasible, as it comes with a predefined structure and fields. Writing that JSON schema by hand, one object per field with label, type, and default value, is itself tedious for anything beyond a handful of fields.
✅ Solution
Use a Power Apps gallery bound to a JSON array to dynamically render input controls on the fly, leveraging AI to quickly generate the form schema.
🔧 How It’s Done
Here’s how to do it:
-
Gallery Setup
🔸 Create a gallery in Power Apps and add all the input fields you might need (text boxes, drop-downs, etc.).🔸 Arrange and style the controls as desired.
-
JSON Data Source
🔸 Use a JSON array as the data source for the gallery.🔸 Load or generate the JSON dynamically (e.g., via AI or stored file).
-
Dynamic Display
🔸 Configure the gallery to render each JSON item as a field.🔸 Each object in the array represents a control with properties like label, type, and default value. Inside the gallery template, a
Switch(ThisItem.type, "text", TextInput_Visible, "dropdown", Dropdown_Visible, "date", DatePicker_Visible, ...)pattern toggles which control isVisiblefor that row, so the gallery template holds one hidden control per supported field type and shows only the one matching the current item. - Add conditional fields 🔸 Beyond a flat list of fields, include an optional
visibleIfproperty in each JSON object (e.g.{"key": "otherReason", "visibleIf": "reason=Other"}) and evaluate it in the control’sVisibleproperty against the values collected so far. This gets you conditional, branching forms, show field B only when field A has a specific value, without changing the gallery structure itself. -
Data Handling
🔸 Save as JSON: collect all inputs into a JSON object and store it.🔸 Power Automate: trigger a flow to parse the JSON for further processing (e.g., send data to SharePoint or Dataverse).
🎉 Result
You get a fully dynamic form that can adapt to various needs and scenarios, far surpassing the capabilities of standard form tools like Microsoft Forms and static Form Controls.
🌟 Key Advantages
🔸 Highly Dynamic: adapt form fields on-the-fly based on conditions or user input, including conditional visibility driven entirely by the JSON schema.
🔸 Data Flexibility: easily save form output as JSON or process with Power Automate.
🔸 No Premium Required: uses only standard Power Apps and Power Automate features.
Two things to validate before trusting an AI-generated schema in production: check that every type value in the generated JSON actually has a matching branch in your gallery’s Switch, an unrecognized type just renders nothing with no error, and confirm required-field validation logic is still enforced explicitly in your Patch/Submit formula, the JSON schema describes what to show, not what Power Apps will refuse to save.
🎥 Video Tutorial
🛠️ FAQ
1. How do I quickly generate the JSON schema for the form?
You can use AI tools like ChatGPT to draft a JSON array schema based on your form requirements, then refine it as needed.
2. Can I include custom control types in the gallery?
Yes. Define each control’s type in the JSON (e.g., dropdown, date picker) and add the corresponding input template to your gallery.
3. Do I need any premium connectors or licenses?
No. This method uses built-in Power Apps galleries, JSON handling, and standard Power Automate flows without requiring premium connectors.
🔗 Related Tips
🔸 Power Apps Dynamic Form Schema: Add Controls on the Fly - a hand-authored version of the same schema-driven approach, without the AI shortcut.
🔸 #PowerPlatformTip 84: ‘Tabbing in Dynamic Forms’ - fix the Tab-key order once your gallery-based form is rendering these AI-generated fields.
This tip is by Marcel Lehmann, Microsoft MVP (Business Applications) and founder of the Power Platform Academy – live Power Platform workshops, free or CHF 49. Join the workshop waitlist to get notified about new dates. For companies that want this implemented for them, see KMUpower – Power Platform consulting & automation for SMEs (DACH).