The LookupPicker control
The LookupPicker control is used to load lookup data from a variety of sources.
The lookup data are not loaded during form startup so this control is the most suitable to display data from large lists.
It allows users to search for the required value using a popup search form, activated by the “Browse” button.
The value of the control is in the following format (when accessed from script using the GetValue() method) :
// Bound to static values
NAME1
// Bound to lookup entity
ID1;#NAME1
Type : LookupPicker
Name
Provides a unique name for the control.
Binding
Indicates if the control is
- Unbound
- Bound to list column
- Is a label for a control bound to list column
Enabled for new records
Sets if the control will be enabled or disabled when the forms handles a new record
Enabled for existing records
Sets if the control will be enabled or disabled when the forms handles an existing record
Required
Marks the cotnrol as Required.
By default, the system recognizes required fields and marks them with this flag. Additionaly, controls can be marked as required event if the bound column is not.
Enabled Formula
Set an expression then will be evaluated during run-time and enable or disable the control.
The expression must be in javascript and should return a boolean value.
Dependencies between controls are automatically identified and the expression is re-calculated every time a control affecting the formula changes.
Example :
form.GetControl(“c_Status”).GetValue() != “Open” && form.UserInGroup(“Administrators”)
Visibility Formula
Define a valid formula (using javascript) that will be evaluated during runtime to show or hide the control.
The expression should return a boolean value.
For example :
form.FieldValue(“c_Status”) != “Rejected” || form.UserID() == “1”
Value
This property defines how the control will get its value.
Here are the available options :
- The value is Static (this is the default for label controls)
- The value will be provided by the user (Not applicable for labels)
- The value will be calculated by a formula
- The value will be retrieved from a list query
- The value will be provided by a web service call
- The value will be provided by a SQL query
Static value
A static text must be set in the appropriate designer control.
Formula
A javascript expression must be set that will provide the value for the control.
If the formula contains references to other controls, dependencies will be automatically identifies during run-time and the value will be updated to reflect changes.
Example :
form.FieldValue(“c_Active”) ? “Yes” : “No”
There is an additional option that instructs the form to perform calculations only for new records. Existing records will keep their original value.
List Query
A predefined list query is bound to the value of the control. So during form initialization, the specified list query is executed and if it returns any item, it selects the first one and it will apply the value to the label based on the following rule :
If a Field Name has been selected in the corresponding box, that specific column will be used from the list item to fill the control value.
If the Field Name is left blank, the first column retrieved will be used.
Web Service
The same as above, the required web service is selected and after the web service retrieves data, the first item will be used to update the control value. If no Field Name is set, the control will receive the first field of the retrieved item.
SQL Query
Works the same way ListQueries and Web Service works.
Default Value
The default value has any effect only of the control is bound to a list column.
For unbound controls, the default value is ignored.
You may set a static value here or use a formula by starting your input with the “equals” (=) sign.
1;#CategoryA
Width
Defines the width of the control.
When the value is zero, the maximum allowed width will be used.
Height
Defines the control height.
If the value is zero, the height property will not be set.
H.Alignment
Defines the horizontal alignment of the parent cell (values : left, right, center)
V.Alignment
Defines the vertical alignment of the parent cell (values : top, bottom, center)
Fore Color
Defines the fore color of the control
Back Color
Defines the Background color of the control.
Cell Color
Defines the color of the parent cell.
Font Size
Declares the font size of the text
Margin
Sets the margin applied to the control, that is, the spacing between the control and the cell borders.
Font Bold
Changes the weight of the font used
Italics
Changes the font style for the control text
This control belongs in the Lookup controls and can provide users with a set of values to select from.
The values can be retrieved from a variety of methods :
List
This is the default method if the underlying column is a lookup column.
Lookup Url
You must define the url of the site containing the target list
Source List
Select the required list from the dropdown control.
Source View
Selecting a view is optional.
If a view is selected then a) the criteria of the view will be combined with the criteria provided here, b) the sorting of the view will be used.
Criteria
You can provide multiple search criteria by opening the criteria editor.
Display Field
Select the field that will be used as the display member of the result set
Value Field
Select the field that will be used as the value member of the result set.
Constraint By
You can select a column of the current record that will be used to filter values from the target list
Match To
If you selected a value for the “Constraint By” property, you must select the column of the target list that will be filtered by the value of the “Constraint By” column.
The form will automatically identify changes in the control bound to the “Constraint by” column and refresh the lookup data.
If the “Constraint By” and “Match To” properties are filled, then the “Query Type” property should be set to set the type of query that will be performed. (Values: Text, Lookup)
Predefined List Query
You may select a List Query already defined in the “List Queries” section of the designer.
All the query parameters (columns retrieved, criteria, sorting, etc) should be defined in the List Query definition.
In the Lookup Details section, users should select the required list query and the Display and Value field of the control. Both fields should be retrieved by the list query.
Web Service
Lookup values from web services can be used as lookup values for controls.
The web service should be already defined in the “Web Services” section of the designer.
The Display and Value fields should be set here by selecting 2 of the fields retrieved by the web service.
Static Values
Static values can be defined as lookup values for a lookup control.
If the underlying column is a choice column, then the list of values cannot be changed by the user.
BDC Data
This option should only be used for SharePoint 2007.
If a control is bound to column that references BDC data then the options here should be already filled in.
You can define the Application instance, the BDC Entity and Display/Value fields.
Managed Metadata
This option should only be used in SharePoint 2010.
SharePoint 2010 supports the definition of data sets across multiple sites and site collections using a hierarchical structure. You can define the TermSet (id or name), the Anchor ID (optional : the guid of the term that will be used as the root term for search) and the “Taxonomy Keyword” checkbox which defines if search will be performed across term sets.
AllowBlankSearchText
Defines if the user is allowed to search the list without providing text-search criteria. Just by pressing Search, the control will load all the available values.
MinChars
Specifies the minimum number of characters required for search. 0 requires no characters entered, 1 requires at least one character, 2 requires at least two characters, etc.
Sorted
Defines if the results will be sorted by the Display Field.
AutoLoadDisplayMember
If selected, the control loads the display field of the record provided – if not included in the value (can be used with external lists).
SaveValueFieldOnly
Set this property to “True” to force the control to send only the Value Member value of the underlying lookup value when saving its value.
Normally lookup controls that load data from other lists, use the ID;#TITLE format to save data
SearchAnyPartOfText
If selected, searches any part of the target column’s value. If not, returns the records that begin with the provided text.
UniqueField
If the internal name of a column is supplied, the retrieved results will be filtered allowing unique values for that specific field.
PopupWidth
Set the width of the pop-up form.
PopupHeight
Set the height of the pop-up form.
AutoComplete
This property enables or disables the auto-complete ability of the control.
Once enabled, you can just start typing on the text area, without clicking on the magnifying glass button, and the control will present you with the matching records, allowing you to select the required value faster.
DisplayFields
Define the fields that will be retrieved and displayed in the results list. It the property is blank, only the display member will be retrieved
SearchFields
Define the fields that you want to search with. It the property is blank, then the display member will be used
Sets the script that will be executed at the value-change event of the control.
Example :
var value = form.GetControl(“c_Title”).GetValue();
if (value == “Open”) form.HideSection(“Details”);
else form.ShowSection(“Details”);
Leave a Reply
Want to join the discussion?Feel free to contribute!