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 (This Post) |
4. Configuring and Extending Share Point Dynamic Forms |
5. XML Specification for Template based rendering |
6. Project @ CodePlex |
Template based rendering in SharePoint Dynamic Forms provide a flexible approach to control the rendering and form submission process. Unlike List Based rendering, this method requires a template file to control the rendering of content. This XML file has to be present in one of the SharePoint List. The list name and the file identifier have to be provided in the configuration section of WebPart.
Unique Features
1. Template based rendering provides the flexibility of deciding what information has to be captured without changing the code base.
2. Enforce validation even if the column does not have its own validation defined in list.
3. Supports extensive field validation types including String, Date, Comparison, Content Length, regex etc.
4. Support for cross field comparison validation.
5. Provides data entry option for a user who doesn’t have write permission to a list.
6. Option to extend the web part by overriding form submission event. This enables validation of input data against custom business logic and inject additional data to list without exposing the field to the end user.
7. Option to cancel the form submission and provide custom notification message.
8. Option for redirection after form submission.
9. Close popup option if data entry form is shown in a Popup.
10. Full control over Save and Cancel button on data entry form.
Steps
1. Download the WSP from CodePlex
2. Deploy the WSP to a Web Application
3. Activate the site collection feature SFS.SharePoint.DynamicForms
4. Navigate to an existing Page or create a new one.
5. Edit the page and click Add a Web Part
6. Locate the Category “Share Point Frontier”
7. Select the Web Part named as “SharePoint Dynamic Form”
8. Once Added , Edit the Web Part
9. This would display the configuration Screen of the WebPart
10. Select “Template” in the Render Mode drop down.
11. Provide necessary values as shown below.
a. Template Source List => Name of the list which contains xml templates
b. Template ID => Identifier value for the XML
c. ID Column => The Display name of the column which contains identifier
d. Data Column => The column in which XML content is present
Sample
For this demo, I have created a template targeting Tasks list and have included the below configurations.
1. Display label change from Title to Task Name, Description to Task Description.
2. Required field validation for Task Description, Due Date and % complete although those fields are not mandatory in the underlying Tasks list.
3. Start date should be at least 2 days greater than current date.
4. Due date should be greater than Start date.
5. % complete should be greater than 10%.
Sample XML Template based on default Tasks List
<?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>
For detailed documentation on XML please refer XML Specification for Template based rendering.
Screens
1. Initial page
2. On Validation
3. After successful submission
On successful submission , notification will be shown to the user.
Leave a comment