, ,

Define List Queries

List Queries is a common method to load results from a SharePoint list (either in the same or any other site of the current site collection).

List Queries can be specified using the LIST-QUERIES section of the runtime designer.

 

Name

Provide a name that will be used to identify the list query in other parts of the designer

Site Url

Set the url of the site that hosts the target list. Hit the “Apply” button in order to load all lists in the specified SharePoint site.

List

Select the target list

View

Optionally you may select a specific view to load data from.

In case a view is selected, the sort ordering defined for that view is used and the “Sort By” parameter is ignored.

Moreover, any criteria defined for the view and added to the criteria of the list query.

Criteria

To specify the records you want to retrieve, you have to setup your lookup criteria using the Criteria Editor.

 

In this criteria editor, you can specify multiple criteria for querying the target list.

For each one, you should specify the following properties :

Target Column

Represents the list column that you want the criteria to apply.

Every column of the target list is available in a dropdown list. The inetrnal names of the columns are used.

Operator

With this property you define the kind of query you want to perform on the target column.

Available options are :

  • Equals
  • BeginsWith
  • Contains
  • Greater
  • GreaterOrEqual
  • Less
  • LessOrEqual
  • NotEquals
  • IsNull
  • IsNotNull
  • In (available in SP2010)

 

Value

In this property, you should type the value that should be used to compare column data with.

The value can be either static or calculated.

For calculated values, you can use control data like the following examples :

Code

{c_ID}

{value:c_Customer}

{name:c_Country}

where the “value:” prefix returns the ID of a lookup control and the “name:” prefix returns the display member of that control.

Type

The Type property defines how the value provided will be handled.

Available values :

  • Text
  • Counter
  • Number
  • DateTime
  • Lookup

If the “Text” type is used a textual comparison will be performed.

for example a query like the following :

Code

ID BeginsWith 1 (Query Type = Text)

will retrieve results with ID = 1 or 12 or 14, although we are dealing with a numeric data type.

The “Counter” and “Number” types perform numeric comparison.

The “DateTime” type uses Date comparison for available column data.

The “Lookup” type should be used when querying a Lookup column and the ID of the column is provided.

for example :

Code

Country Equals {value:c_Country} (Query Type = Lookup)

assuming that the c_Country control is a lookup control loading country data.

If you want to perform a query on the Title of the country, you should something like the following :

Code

Country Equals {name:c_Country} (Query Type = Text)

 

Ignore Blank

Use this property if you want to apply criteria only if the value provided is not blank.

If the value is blank, the criteria will be skipped.

For example, you may want to add a combobox with Cities (c_City) in your form and you want to filter cities be their country which is another combobox on the same form (c_Country)

The tricky part is that you want to load ALL available cities in the cities combobox when the country combo is blank.

In the above scenario, you should add the following criteria in the cities combobox (in the Lookupp Details tab)

Code

Country Equals {value:c_Country} (Type=Lookup, IgnoreBlank=YES)

or

Country Equals {name:c_Country} (Type=Text, IgnoreBlank=YES)

LeftParenthesis – RightParenthesis

These properties are used to group criteria together and perform complex queries.

For example queries like the following can be performed using these properties :

Code

(Priority = High OR Normal) AND (Status = Resolved OR Canceled)

Clause

The clause is the operator that binds criteria together.

Availble values : AND, OR

Columns

The columns that will be retrieved from the target list must be specified here, separated by semicolon.

The internal column names must be used.

Headers

Optionally, you can define column headers for the retrieved data.

These headers will be used when the list query will be bound to a DataGrid control and only if no specific Fields have been specified for that control.

Sort By

Define the column that will be used to sort data.

Ascending

Set if the sort order will be ascending or descending

Max Rows

Defines the number of results returned from a list query. 0 returns all records, all numbers greater than 0 will limit the displayed results respectively.

, ,

Show or Hide a control based on form conditions

In order to hide/show controls on the form, we can either use the “Visibility Formula” which is inside the control properties window in the designer, or write some script to perform the same action.

Examples :

Condition based on the value of another control :

Code

form.GetControl(“c_Status”) != “Rejected”

Condition based on logged in user :

Code

form.UserID() == “1” || form.UserInGroup(“Administrators”) || form.UserInGroup(“3”)

Visibility from script

Inside the Value-Change event of the “c_Customer” control :

Code

var target = form.GetControl(“c_Priority”);

var source = form.GetControl(“c_Customer”);

if (source.GetValue() == “1;#BPC”) target.SetVisible(false);

else target.SetVisible(true);

, ,

Enable or Disable a control based on form conditions

One of the most common scenarios when designing a custom form, is the requirement to enable/disable a specific control (or set of controls) based on a) the values of other controls, b) the user using the form.

For our example, we have a list with the following columns :

Customer (lookup column referencing the Customers list)
Priority (Choice column with values : Normal, High, Low)

The scenario requires that if a specific customer is selected, the Priority ComboBox should be set to Priority=High and should be disabled for the user.

When first opening the form, it should show something like the following :

 

You can enable or disable controls using 2 different approaches :

Enabled Formula

Open the designer and select the Priority ComboBox properties.

In the Enabled formula add the following expression :

Code

form.GetControl(“c_Customer”).GetValue_Name() != “BPC”

NOTE : In the expression above, we only check for the display member of the combobox value. If we wanted to check for the value member (ID) we would have to write something like :

Code

form.GetControl(“c_Customer”).GetValue_Value() != “1”

// or

form.GetControl(“c_Customer”).GetValue() != “1;#BPC”

When the user selects a different customer, the Priority combo is enabled :

But if we select the customer appearing in the formula, the control is automatically disabled :

Now to completely meet the requirements, we have to set the value to “High”.

This can be accomplished using a simple script inside the Value-Change event of the Customer ComboBox.

The script should be something like the following :

Code

if (form.Loaded) {

  value = form.GetControl(“c_Customer”).GetValue_Name();

  if (value == “BPC”) form.GetControl(“c_Priority”).SetValue(“High”);

}

 

The form.Loaded condition is used because we want this script to be executed only after the user changes the value and not during form initialization (the value-change events are raised during form loading).

Using script

The same thing can be accomplished without using the Enabled formula but by script alone.

Here is the changed script that we should use to have the same effect.

The script should handle the value-change event of the Customer ComboBox.

Code

value = form.GetControl(“c_Customer”).GetValue_Name();

if (value == “BPC”) {

form.GetControl(“c_Priority”).SetEnable(false);

if (form.Loaded) form.GetControl(“c_Priority”).SetValue(“High”);

}

else {

  form.GetControl(“c_Priority”).SetEnable(true);

}

 

Notes :

In the above script, we check the customer value and we set the Enabled property of the Priority control.

We set the default value only when the event was raised from a user action and not due to form initialization.

 

, ,

The Slider control

The Slider can be used instead of a numeric textbox. Moving the slider left or right increases or decreases the number. The Slider can store its data in a single line column or a numeric column.

 

 

Type : Slider

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 :

Code

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 :

Code

form.FieldValue(“c_Status”) != “Rejected” || form.UserID() == “1”

Value

This property defines how the control will get its value.

 

Here are the available options :

  1. The value is Static (this is the default for label controls)
  2. The value will be provided by the user (Not applicable for labels)
  3. The value will be calculated by a formula
  4. The value will be retrieved from a list query
  5. The value will be provided by a web service call
  6. 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 :

Code

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.

Example :

Code

=”User : ” + form.UserFullName()

Width

Defines the width of the control.

When the value is zero, the maximum allowed width will be used.

Please note that you can only change the Slider’s width using the above Layout property and not by adjusting the number of boxes it occupies on the designer view.

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

Not Applicable for the Slider control.

Back Color

Not Applicable for the Slider control.

Cell Color

Defines the color of the parent cell.

Font Size

Not Applicable for the Slider control.

Margin

Sets the margin applied to the control, that is, the spacing between the control and the cell borders.

Font Style

Not Applicable for the Slider control.

Not Applicable for this control

MinimumValue

Indicates the minimum value for the progress bar.

MaximumValue

Indicates the maximum value for the progress bar.

SmallChange

Indicates the least amount of change in the value that can happen by moving the slider.

LargeChange

Indicates the most amount of change in the value that can happen by moving the slider.

Decimals

Sets the number of decimals for the displayed value, default is 0.

Sets the script that will be executed at the value-change event of the control.

Example :

Code

var value = form.GetControl(“c_Title”).GetValue();

if (value == “Open”) form.HideSection(“Details”);

else form.ShowSection(“Details”);

 

, ,

The RotatedText control

An example of a RotatedText control with Font Bold and an Angle of 45:

Type : RotatedText

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 :

Code

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 :

Code

form.FieldValue(“c_Status”) != “Rejected” || form.UserID() == “1”

Value

This property defines how the control will get its value.

 

Here are the available options :

  1. The value is Static (this is the default for label controls)
  2. The value will be provided by the user (Not applicable for labels)
  3. The value will be calculated by a formula
  4. The value will be retrieved from a list query
  5. The value will be provided by a web service call
  6. 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 :

Code

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.

Example :

Code

=”User : ” + form.UserFullName()

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

Not Applicable for this control

Angle

The angle of the text transformation

, ,

The RichTextBox control

A Rich Textbox control is generally used for displaying, entering and manipulating text with formatting. The RichTextBox control does everything a textbox control does, but it can also display fonts, colors, links, margins, load text and images from a file. Although it adds more complexity when compared to a regular textbox, it provides much needed features.

The RichTextBox control can be used with any Sharepoint text field, but it order to unlock all its features you have to bind it to a textbox defined with multiple lines of text. It automatically recognizes the type of text allowed with the rich textbox field and enables or disables the features available for use, as shown below:

Multiple line of Text columns with Plain Text mode selected, the RichTextBox control renders as a simple TextBox with no additional options to format text.

For Enhanced rich text columns, the control displays all the available toolbar options.

Type : RichTextBox

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 :

Code

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 :

Code

form.FieldValue(“c_Status”) != “Rejected” || form.UserID() == “1”

Value

This property defines how the control will get its value.

 

Here are the available options :

  1. The value is Static (this is the default for label controls)
  2. The value will be provided by the user (Not applicable for labels)
  3. The value will be calculated by a formula
  4. The value will be retrieved from a list query
  5. The value will be provided by a web service call
  6. 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 :

Code

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.

Example :

Code

=”User : ” + form.UserFullName()

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

Not Applicable for the RichTextBox control.

Back Color

Not Applicable for the RichTextBox control.

Cell Color

Defines the color of the parent cell.

Font Size

Not Applicable for the RichTextBox control.

Margin

Sets the margin applied to the control, that is, the spacing between the control and the cell borders.

Font Style

Not Applicable for the RichTextBox control.

Not Applicable for this control

AutoHideToolbar

When this property is set to true, the Editor’s toolbar is hidden by default and is auto-displayed when the control receives focus.

FontNames

Font names separated by semilocon (;) to be used in the font dropdown list of the rich textbox editor. If empty, the default font list is used.

AutoSizeViewMode

When this property is set to true, in ViewMode, the control’s height is adjusted according to its value.

Sets the script that will be executed at the value-change event of the control.

Example :

Code

var value = form.GetControl(“c_Title”).GetValue();

if (value == “Open”) form.HideSection(“Details”);

else form.ShowSection(“Details”);