BPC-Components

Home > Products > BPC PowerForms - Silverlight > Knowledge Base > Scripting and Formulas > Set Default Values

Set Default Values


The Default Value property is used to set the value of the control for new records.

The default value can be either static or calculated.

 

For static values, just enter the required value in the default value field. For labels and textboxes just enter the required text. For lookups, enter the ID of the required record. For choice fields, enter the choice text. For boolean fields, set 1 or 0. For numeric fields, set the number you want. For date fields set the date in the format : yyyy-MM-dd

 

For calculated values, you must enter the required expression starting with the "=" sign. Any of the available functions may be used.

 

Examples:

 

Static default value for date field : 2010-01-01

Current date :

Code

=today()

 

Current date plus 10 days :

Code

=adddays(today()+10)

 

First day of the next month :

Code

=date(year(addmonths(today(), 1)), month(addmonths(today(), 1)), 1)

 

First day of the year :

Code

=date(year(today()), 1, 1)

 

For a PeoplePicker control, you can use the following formula to select the current user.

Code

=UserID() & ";#" & LoginName()

=UserID() & ";#" & UserFullName()

 

Lookup queries for default values

 

Special calculation formula functions can be used to lookup values from any list. These formulas are evaluated in an asynchronous mode.

 

Code

GetListItemValue(URL, LIST_NAME, LIST_ITEM_ID, FIELD_NAME)

Returns the value of a field

 

Code

GetListItemValueD(URL, LIST_NAME, LIST_ITEM_ID, FIELD_NAME)

Returns the display value of a field (for lookup fields)

 

Code

GetListItemValue(URL, LIST_NAME, LIST_ITEM_ID, FIELD_NAME)

Returns the value (ID) of a field (for lookup fields)

 

Example :

Code

=GetListItemValueD("http://servername", "Accounts", "1", "Address")