Pre-populate fields in Forms via URL parameter?

Is there a way to pre-populate a field on a form using a parameter that is attached to the form's URL?

Idea/scenario behind this: We could send out personalized links to people from whom we'd like to gather some information, e.g. https://[my-form-url]?UserID=27

Result: When the receipient opens the link in the browser, the field "UserID" would already be filled with the value 27 without the need to enter the number manually.

Hello @Matheus_Felipe,

Welcome to Plumsail Community!

You can populate form fields with data from query parameters using the code.

    const queryString = window.location.search;
    const urlParams = new URLSearchParams(queryString);
    //populate field with CustomerID query parameter
    fd.field('User').value = urlParams.get('UserID');

Place the code inside fd.rendered if you are suing Public web forms, and inside fd.spRendered for SharePoint forms.

1 Like

Hello, thanks for you answer,
how i can pre populate the form, with ID from sharepoint list?

When I create a NEW ITEM in a sharepoint list, automatically (by power automate) I send a public plusmail form, to the receiver of the form "with the same id that was created in pre-populated sharepoint, so that when the user answers the form, the answers are added to the "item created in the sharepoint list related to the ID

@Matheus_Felipe,

You can build a link with multiple query parameters like this:
https://[my-form-url]?UserID=27&ID=2

And on the form, populate the SharePointID field using the same code that I've shared.

Very useful, but it doesn't work for me when I post it on a page, it only works when it's the form alone. Can you help me?

Hello @XPO-IT,

The idea behind this approach is to share a direct link to the form and set field values based on the user receiving the link.

What is your case?

If you want to pre-populate the form with some default values for all users, you can do that with code:

fd.spRendered(function(){
   //populate field value on form load
   fd.field('Title').value = 'Default Title';
});