SharePoint Dynamic Forms XML Specification

Ashok Raja
 
Solutions Architect
August 20, 2012
 
Rate this article
 
Views
181


Links to other posts in Dynamic Forms Series
1. Introduction to SharePoint Dynamic Forms
2. List Based Rendering of Share Point Dynamic Forms
3. Template Based Rendering of Share Point Dynamic Forms
4. Configuring and Extending Share Point Dynamic Forms
5. XML Specification for Template based rendering (This Post)
6. Project @ CodePlex

 

The template based form generation in SharePoint Dynamic Forms requires XML specification as input. This XML file contains information about the list, columns and its validation rules. This blog post explains the options available in the XML template in respect to version 1.0 of SharePoint Dynamic Forms.

Let’s begin with a sample xml file and dive deep into the options available to control the rendering of Dynamic Form

 <?xml version="1.0" encoding="utf-8" ?>
 <DynamicForms>
 	<Form ListName="Tasks" DisplayName="Daily Task List">
 		<Fields>
 			<Field InternalName="Title" DisplayName="Task Name">
 			</Field>
 			<Field InternalName="Body" DisplayName="Task Description">
 				<Validations>
 					<Rule Type="re" Value="True"></Rule>
 				</Validations>
 			</Field>
 			<Field InternalName="StartDate" DisplayName="Start Date">
 				<Validations>
 					<Rule Type=">" Value="[TODAY]+2d"></Rule>
 				</Validations>
 			</Field>
 			<Field InternalName="DueDate" DisplayName="Due Date">
 				<Validations>
 					<Rule Type="re" Value="True"></Rule>
 					<Rule Type="==" Value=">|StartDate"></Rule>
 				</Validations>
 			</Field>
 			<Field InternalName="PercentComplete" DisplayName="% Complete">
 				<Validations>
 					<Rule Type="re" Value="True"></Rule>
 					<Rule Type=">" Value="10%"></Rule>
 				</Validations>
 			</Field>
 		</Fields>
 	</Form>
 </DynamicForms>

DynamicForms is the root element of the XML and it can have only one Form element. As of now Dynamic Forms does not support multiple lists in a single form so the option for multiple forms is ruled out. Form element can also have only one Fields element which in turn can have multiple Field elements. Literally the field element represents each column in that list and is uniquely identified with its internal name. Field elements can have any number of Rules enclosed inside single Validation element.

Form Element

Attribute Name

Description

Sample Value

ListName

Name of the target list that should be used to locate the columns

Tasks

DisplayName

Will be used as Form Title if Show Form Header in Display Settings is selected

Daily Task List

Field Element

Attribute Name

Description

Sample Value

InternalName

Internal Name of the column

Title

DisplayName

Caption to be used for Input fields, if unavailable Internal name will be used as DisplayName

Task Name

Rule Element

Attribute Name

Description

Sample Value

Type

Validation Type, more like operators

=, !=, (), )(,re

(Refer rule type for available options)

Value

Caption to be used for Input fields, if unavailable Internal name will be used as DisplayName

[TODAY]+2d

10%

123

ErrorMessage

Custom Error Message for this rule. If blank, default error message will be displayed. Accepts “[fld]” as a replaceable token which would be replaced with Display Name of field

[fld] cannot contain the word test.

Rule Types

Symbol

Description

Applicable To Column Types

Example

re

Required Field

All Columns including lookup

<Rule Type="re" Value="True"/>

ml

Min Length

String Columns (Text, Note)

<Rule Type="ml" Value="5"/>

xl

Max Length

String Columns

<Rule Type="xl" Value="10"/>

fl

Fixed Length

String Columns

<Rule Type="fl" Value="3"/>

>

Greater Than

Date and Numeric Columns (Number, Integer, Currency)

<Rule Type=">" Value="10"/>

>=

Greater Than Equal

Date and Numeric Columns

<Rule Type=">=" Value="[TODAY]"/>

<

Less Than

Date and Numeric Columns

<Rule Type="<" Value="10.5"/>

<=

Less Than Equal

Date and Numeric Columns

<Rule Type="<=" Value="15%"/>

=

Equal

Date, Numeric, String Columns

<Rule Type="=" Value="Sample"/>

!=

Not Equal

Date, Numeric, String Columns

<Rule Type="!=" Value="100"/>

=>

Range

Date, Numeric Columns

<Rule Type="=>" Value="5|95"/>

==

Compare

String, Numeric, Date Columns

<Rule Type="==" Value=">|CostPrice"/>

rx

RegEx

String Columns

<Rule Type="rx" Value="[a-z]"/>

()

Contains

String Columns

<Rule Type="()" Value="test"/>

)(

Does not Contains

String Columns

<Rule Type=")(" Value="test"/>

Value Options for Specific Data Types

Date

Value

Description

20-Aug-2012

Specific date. Should be in dd-MMM-yyyy format

[TODAY]

Current Date

[TODAY]+2d

Current Date + 2 days

[TODAY]+2m

Current Date + 2 Months

[TODAY]+2y

Current Date + 2 years

[TODAY]-2d

Current Date – 2 days

[TODAY]-2m

Current Date – 2 Months

[TODAY]-2y

Current Date – 2 Years

Range

Value

Description

5|95

Range between 5 and 95 , including both the values. Values are separated with pipe symbol .

Percentage (%)

Value

Description

10%

If the column type is percentage, value can contain % symbol

Compare

Value

Description

InternalName|Operator

It’s a combination of Internal Name of a field and an operator separated by pipe symbol.

>|CostPrice

Let’s assume that this validation rule is set to a field Selling Price. This enforces a rule that the selling price should be greater that cost price. If this condition is set in Cost Price the rule would be “<|Sellingprice>”

>|StartDate

Should be greater than value of Start Date field

Author Info

Ashok Raja
 
Solutions Architect
 
Rate this article
 
I am Ashok Raja, Share Point Consultant and Architect based out of Chennai, India. ...read more
 

Leave a comment