---
title: Automatic Template Binding
slug: automatic-template-binding
createdAt: 2026-05-04T01:58:55.054Z
---

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.

```csharp
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&#x20;
- Select-style controls such as SelectUser&#x20;
- Forms displayed for selected objects&#x20;
- Role-based or resource-based form configuration&#x20;

## 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.

:::BlockQuote
\<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.

:::BlockQuote
\<FormName>.Template
:::

For example:

:::BlockQuote
WebForm.Template
:::

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:

:::BlockQuote
//Roles/User Types/WebForm
//Roles/User Types/WebForm.Template
:::

In this pattern:

- WebForm defines the form&#x20;
- WebForm.Template defines the binding template&#x20;
- When WebForm is bound into the job, the template is applied automatically&#x20;

## Benefits

Automatic Template Binding helps simplify form development by:

- Reducing custom server-side code&#x20;
- Making form behaviour easier to maintain&#x20;
- Keeping template logic closer to the form configuration&#x20;
- Improving consistency across forms&#x20;
- Supporting dynamic form behaviour with less manual scripting&#x20;

## Migration Notes

When updating older forms:

1. Identify custom code that manually applies templates using ApplyXml&#x20;
2. Move that logic into a BindingTemplate or .Template parameter where possible&#x20;
3. Remove the custom code once the automatic template has been verified&#x20;
4. Test the form to confirm job arguments are populated correctly&#x20;

## 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.
