Automatic Template Binding
9 min
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 \<formname> template for example 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 //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