Using query string parameters for default/calculated values

When dealing with default or calculated values in a form you can now use the new queryString() function to set these values directly from the URL address that the users are using to open up a form. 

In order to use this feature, following steps must be taken:

  1. queryString() formula needs to be used in default/calculated value definition
  2. proper URL needs to be set up

 

Using the queryString() function

The function needs to be simply typed in the default formula or the calculated formula fields on a field. See more details in related articles (default values, calculated values).

Syntax of the function is: queryString(<name_of_query_parameter>), e.g. queryString("parameterOne").

  Note

As default/calculated values mechanism expects a javascript expression, it is possible to combine usage of queryString function call with using a fallback value. Example:

queryString("parameterName") ? queryString("parameterName") : "A default value"

The above formula will try to use the value of "form_parameterName" parameter present in the URL. If it won't be found, the "A default value" text will be used instead.

Setting up the URL

Values returned by the queryString() function are retrieved from the URL that has been used to open up a form in Sintel Forms. Therefore you need to extend the URL with proper key-value pairs by appending following text to it:

&form_<parameterName>=<value>
Note that the name of parameter needs to be prefixed with a "form_" text.

  

URL parameter examples

Text field value for "defaultTitle" parameter:

&form_defaultTitle=This is a default query parameter

Number field value for "defaultNumber" parameter:

&form_defaultNumber=12.34

Choice field value for "defaultChoice" parameter: 

&form_defaultChoice=Choice One

Multi choice field value for "defaultMultiChoice" parameter (comma separated values are used):

&form_defaultMultiChoice=Choice One,Choice Two

Lookup field value for "defaultLookup" parameter (the id of lookup item is provided):

&form_defaultLookup=1

User field value for "defaultUser" parameter (the email of a user is provided):

&form_defaultUser=user@domain.com

Combining URL parameters: 

&form_parameter1=user@domain.com&form_parameter2=A value&form_parameter3=123

URL parameters need to be appended to an URL that points to list item creation/edition page.

For anonymous forms, you can use the anonymous access link that can be copied from Forms Designer.

For regular forms, you can use the default SharePoint list item URLs. For instance, an example link for adding a new item to the list is:

https://sintelit.sharepoint.com/sites/nameOfTheSite/Lists/nameOfTheList/NewForm.aspx

After you add query parameters to this, it will look as follows:

https://sintelit.sharepoint.com/sites/nameOfTheSite/Lists/nameOfTheList/NewForm.aspx?form_parameterOne=1&form_parameterTwo=A default value

Was this article helpful?
0 out of 0 found this helpful