One of the most underused tricks in model-driven app development is the ability to pass data directly into a form via query string parameters and use that data to prepopulate fields when the form loads.
Whether you’re embedding forms in external portals, triggering them from other apps, or launching forms via buttons or Power Automate flows, this technique unlocks cleaner user experiences and smarter defaults.
This post walks through how to:
- Configure a model-driven form to accept custom query parameters
- Use JavaScript to read and apply those values to the appropriate fields
Scenario: Pre-fill a Form with External Data
Imagine you want to:
- Launch a Lead form from an email campaign with the source campaign pre-filled
- Open a Case form from a custom app and set the customer and subject
- Pre-fill hidden metadata like referral codes, flags, or contextual data not stored in the URL by default
Instead of manually handling this in Power Automate, you can dynamically populate form fields at runtime using parameters passed in the URL.
Step 1: Configure the Form to Accept Custom Parameters
Start by enabling the form to receive custom parameters.
- Go to your model-driven app form in the Power Apps Maker portal
- Open the form designer
- In the left panel, select Form Settings (⚙️ gear icon)
- Scroll to Parameters
- Click + Add parameter
- Set:
- Name: e.g.,
sourceCampaign - Data type: String, Integer, Float, Boolean, or DateTime
- Required: Optional unless it’s critical to form logic
- Name: e.g.,
This defines which parameters the form can accept from the query string.
Step 2: Pass the Parameters in the Form URL
Let’s say you’re opening a new Lead record.
The typical URL might be:
https://<org>.crm.dynamics.com/main.aspx?appid=<appId>&pagetype=entityrecord&etn=lead
Add your custom parameter like this:
&extraqs=sourceCampaign=Spring2025
Note:
extraqsis a special query string property that holds custom parameters- You can pass multiple parameters like this:
&extraqs=sourceCampaign=Spring2025&isReferral=true
Step 3: Set Field Values Using the Parameters (via JavaScript)
To actually populate the form fields using the parameters, use client-side scripting in the form’s OnLoad event.
Example Script
function setFieldsFromParameters(executionContext) {
const formContext = executionContext.getFormContext();
const params = formContext.getAttribute("customParameters");
if (!params) return;
// Read parameters and set field values
if (params.sourceCampaign) {
formContext.getAttribute("campaignid").setValue([
{
id: params.sourceCampaign,
entityType: "campaign",
name: "Spring 2025"
}
]);
}
if (params.isReferral === "true") {
formContext.getAttribute("new_isreferral").setValue(true);
}
}
How This Works:
formContext.getAttribute("customParameters")returns a dictionary of custom parameters defined in the form- You can use them to populate:
- Lookups
- Option sets
- Two-options (Boolean)
- Strings, numbers, dates
Pro Tips & Gotchas
- Enable parameters per form – If you have multiple forms for the same table, configure each one separately
- Test URLs in private tabs – Especially if you cache forms via deep links or pinned tabs
- Don’t assume type coercion – Everything comes as a string. Convert to Boolean, Int, or Date manually
- Validate presence of expected fields – In case someone tampers with URLs or values are missing
- Use
showProgressIndicator()if you’re waiting on lookups or async data to populate fields

Hi, thanks for article. I want to mentioned the UI Form doesn’t need any setting. Parameters work auromatically.
LikeLiked by 1 person