Pass values in a form's link to fill in fields when the form opens. For example, a link from another business application can open an HR form with the employee's name already filled in, while still letting the user change it.
Add values to the link
Add the values after a question mark at the end of the form link, as name=value pairs joined by &:
https://forms.example.com/view/#!/form/<form ID>?firstname=John&lastname=Doe
If the link already contains a question mark (for example ?header=0), don't add another one. Join the new values with & instead.
Values in a link must be URL-encoded. Letters and numbers are safe. Spaces and special characters such as &, #, ? or + must be encoded, for example a space as %20. Most applications that build links have a function for this, such as encodeURIComponent in JavaScript.
Read the values into a field
Use a Custom Default Value on the component to fill. It runs when the form opens, and the user can still change the value afterward.
-
Open the settings of the component, for example Employee Name, and select the Data tab.
-
Expand Custom Default Value → JavaScript Default and enter:
JavaScript// Read the values after the ? in the form link. var params = new URLSearchParams(window.location.hash.split('?')[1] || ''); if (params.get('firstname') && params.get('lastname')) { value = params.get('firstname') + ' ' + params.get('lastname'); } -
Save the component and open the form with the values in its link to test.
The first line can be copied into any similar script. params.get('name') returns the value for that name, already decoded, or nothing if it isn't in the link.
Fill a single field
var params = new URLSearchParams(window.location.hash.split('?')[1] || '');
value = params.get('department') || '';
Things to know
-
Values from the link are only used when the field is empty, so they don't overwrite data in a saved submission.
-
Anyone can change values in a link. Treat them as a convenience for the user, not as trusted data. If a value must not be changed, look it up instead, for example with an SQL lookup.
-
Don't put confidential information in links. Links are kept in browser history and server logs, and can be forwarded.