BPC-Components

Home > Products > BPC PowerForms - Silverlight > Knowledge Base > General > Set Default Values using the querystring

Set Default Values using the querystring


In the Querystring, you can define values that will be used as default values for a new record. The keyword "ID" is reserved and when used in the querystring, the form tries to load the record with the ID specified. All the other field names can be used to apply default values in the form of :

Code

http://<servername>/<site>/New.aspx?<FieldName1>=<Value1>&<FieldName2>=<Value2>...

For example :

We want to set the Category field (combobox lookup to another list) to 1, the Evaluation field (choise) to Negative, the PublishedDate field to the current date and the Priority field (popup lookup picker) to 3;#Medium.

The querystring should look like this :

Code

http://url_to_form/page.aspx?Category=1&amp;Evaluation=Negative&amp;PublishedDate=%3Dtoday()&amp;Priority=3;%23Medium

Notice that in the DateField we are actually applying a formula to the default value (=today()) and we escape the '=' character with %3D. We also have to escape the # character with the %23 equivalent.

NOTE : The keywords : "Type", "RootFolder", "ID" and "Source" are reserved from SharePoint and cannot be used as querystring default values. 

Use Case : Applying default values from a "parent" entity

We have 2 lists :

1. Customers. Columns : ID, Title

2. Orders. Columns : ID, Title, Date, Customer (Lookup for Customers)

In order to add multiple orders for the same customer, we should add a hyperlink control in the customer form.

The value of the control should be the absolute url of the NEW ORDER item. For example :

http://ServerName/Lists/Orders/NewForm.aspx?Source=xxxxx

In order to apply default value for the customer field, we make the hyperlink control calculated and we apply the following formula :

Code

http://ServerName/Lists/Orders/NewForm.aspx?Source=xxxxx&Customer={c_ID};%23{c_Name}

We use the following format since the default value should be in the ID;#Title format.

This allows the users to navigate to the New Order form directly from the customer form and execute multiple SAVE (NOT Save and Exit) and NEW actions without having to set the Customer field.