Automatic Template Binding
Automatic Template Binding allows Activate Web Forms to apply a binding template to a form automatically when the form is bound into the job.
This removes the need for form authors to manually apply template XML in server-side code.
Role userType = Job.Arguments.GetObject("data/roles/type") as Role;
if(userType != null)
Job.Arguments.ApplyXml(userType.GetParameters("Template*"), ValidatedXmlValue.ApplyArgumentFlags.ApplyTemplate);In most cases, this type of custom binding code can be removed.
When to Use Automatic Template Binding
Use Automatic Template Binding when a form needs to populate or update job arguments based on a selected item, role, resource, or other object.
It is especially useful when working with:
- FormPanel
- Select-style controls such as SelectUser
- Forms displayed for selected objects
- Role-based or resource-based form configuration
How It Works
When a form is bound into the job, Activate checks for a binding template associated with that form.
If a template is found, Activate applies it to the job arguments automatically.
This allows the selected object or form context to populate the required data without additional scripting.
Defining a Binding Template
A binding template can be defined in either of the following ways.
Option 1: Embed the Template in the Form
Add a BindingTemplate element directly inside the form definition.
<BindingTemplate> </BindingTemplate>
Use this when the template is specific to the form and should be maintained with the form definition.
Option 2: Use a Template Parameter
Create a parameter using the form name with .Template appended.
For example:
This parameter can contain the template directly or reference another parameter.
Use this approach when the template should be managed separately from the form definition or reused across forms.
Example
Example locations:
//Roles/User Types/WebForm //Roles/User Types/WebForm.Template
In this pattern:
- WebForm defines the form
- WebForm.Template defines the binding template
- When WebForm is bound into the job, the template is applied automatically
Benefits
Automatic Template Binding helps simplify form development by:
- Reducing custom server-side code
- Making form behaviour easier to maintain
- Keeping template logic closer to the form configuration
- Improving consistency across forms
- Supporting dynamic form behaviour with less manual scripting
Migration Notes
When updating older forms:
- Identify custom code that manually applies templates using ApplyXml
- Move that logic into a BindingTemplate or .Template parameter where possible
- Remove the custom code once the automatic template has been verified
- Test the form to confirm job arguments are populated correctly
Best Practice
Prefer Automatic Template Binding over custom server-side template application wherever possible.
Use server-side code only when the binding logic cannot be represented cleanly through a template.