#PowerPlatformTip 80: 'Rapid Dynamic Forms with AI'
TL;DR: Describe the form as a JSON array (one object per field), let an AI assistant write that JSON for you, load it with
Table(ParseJSON(...))into a gallery, show the matching input control per row, and collect the answers fromGallery.AllItemsinto a JSON result.
💡 Challenge
A Form control needs a data source with fixed columns, so it can’t render a field list that changes per use case. Building one screen per form variant is slow, and writing a field schema by hand (label, type, options for every field) is tedious once a form has more than a handful of fields.
✅ Solution
Drive the form from data. A JSON array describes the fields, a gallery renders one row per field, and each row shows only the input control that matches the field’s type. An AI assistant (Microsoft 365 Copilot, ChatGPT or similar) writes the JSON from a plain description of the form.
🔧 How It’s Done
1. Let the AI write the schema
🔸 Example prompt: “Create a JSON array for a vacation request form. Each object has the properties key, label, type (text, date or dropdown) and, for dropdowns, options as an array of strings. Return only the JSON.”
🔸 Example result:
1
2
3
4
5
6
[
{"key": "name", "label": "Name", "type": "text"},
{"key": "start", "label": "Start date", "type": "date"},
{"key": "end", "label": "End date", "type": "date"},
{"key": "reason", "label": "Reason", "type": "dropdown", "options": ["Vacation", "Training", "Other"]}
]
🔸 Store the JSON where the app can read it: a text column in SharePoint or Dataverse, an environment variable, or for a first test a named formula or a multiline text input txtSchema.
2. Load the schema into a gallery
// galForm.Items
Table(ParseJSON(txtSchema.Text))
🔸 ParseJSON returns an untyped object, Table() turns the array into a table with one record per field. Each record has a single column Value, so the field properties are read with ThisItem.Value.label and converted with Text().
3. Build the template: one control per type
🔸 Add a label and one input control per supported type to the gallery template:
// lblField.Text
Text(ThisItem.Value.label)
// txtValue.Visible
Text(ThisItem.Value.type) = "text"
// dpValue.Visible
Text(ThisItem.Value.type) = "date"
// ddValue.Visible
Text(ThisItem.Value.type) = "dropdown"
// ddValue.Items
ForAll(Table(ThisItem.Value.options), Text(ThisRecord.Value))
🔸 Only the control that matches the row’s type is visible. The dropdown reads its choices from the options array of the same row.
4. Collect the answers
🔸 Gallery.AllItems contains the records of the gallery including the current values of the controls in the template. Build the result on the submit button:
// btnSubmit.OnSelect
Set(
varResult,
JSON(
ForAll(
galForm.AllItems,
{
key: Text(ThisRecord.Value.key),
value: Switch(
Text(ThisRecord.Value.type),
"text", txtValue.Text,
"date", Text(dpValue.SelectedDate, "yyyy-mm-dd"),
"dropdown", ddValue.Selected.Value
)
}
)
)
)
🔸 varResult now holds the answers as JSON, for example [{"key":"name","value":"Anna"},{"key":"start","value":"2026-07-01"}, ...].
5. Process the result
🔸 Write varResult into a text column of your list or table, or pass it to a flow (Power Apps (V2) trigger with a text input). In the flow, the Parse JSON action turns it back into fields you can map.
🎉 Result
A new form is a new JSON array, not a new screen. The same gallery renders any field list your schema describes, and every submission arrives as one JSON document with key/value pairs.
🌟 Key Advantages
🔸 Fast: the AI writes the schema, you only review it.
🔸 One screen for many forms: the gallery stays the same, the JSON changes.
🔸 Portable output: answers are JSON, ready for a flow or a text column.
⚠️ Good to Know
🔸 A type without a matching control in the template shows only the label and no input. Check every type in an AI-generated schema against the controls you built.
🔸 The schema describes what to show, not what is required. Add a required property to the schema and check it before saving, for example CountRows(Filter(galForm.AllItems, Boolean(ThisRecord.Value.required) && Text(ThisRecord.Value.type) = "text" && IsBlank(txtValue.Text))) = 0 before the Set runs.
🔸 Licensing: galleries, ParseJSON and a flow with the Power Apps trigger and SharePoint actions are standard. If you store the result in Dataverse, the app and flow need a premium license.
🎥 Video Tutorial
🛠️ FAQ
1. How do I quickly generate the JSON schema for the form?
Describe the form in a prompt and ask for a JSON array with fixed property names (key, label, type, options). Fixed names matter, because the gallery formulas read exactly these properties.
2. Can I add more control types?
Yes. Add the control to the gallery template, set its Visible to Text(ThisItem.Value.type) = "yourtype" and add a branch for it in the Switch of the submit formula.
3. Do I need any premium connectors or licenses?
Not for the form itself. Galleries, ParseJSON, JSON and a flow with SharePoint are standard. Dataverse as storage is premium.
🔗 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 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).