Autofill Description from Template
Overview
Catalog items can store a dynamic template string (in custom fields u_dynamic_description_template and u_dynamic_short_description_template on the catalog item) that describes how to build the description and short_description of a resulting RITM from its variables. Two Business Rules — running on sc_req_item — read that template, substitute in variable values, and write the result back onto the record.
The templates are written in a small text mini-language with three tokens:
VAR.field— replaced with the raw value of the catalog variable namedfield.REF.field(table)— treatsfieldas a reference variable (a sys_id) and replaces the token with that record’s display value, looked up ontable.CONSW.field(value1:1,value2:2,...)— a “conditional switch.” It reads the current value of variablefield, maps it to a numbered template block (value1maps to block1,value2to block2, etc.), and replaces the entire template with just that block before theVAR/REFsubstitution runs. Blocks are written inline as1)...text...,2)...text..., terminated by a trailing$).
Problem Statement
Different catalog items need very different description text, and a single item can even need different text depending on a variable’s value (e.g. a “Server Request” item behaves differently for “new server” vs. “decommission”). Hardcoding this logic per catalog item in separate business rules would be unmaintainable or would need to have custom flows for each catalog item instead of being able to use an single flow for many items. Instead, the wording lives as data template string stored on the catalog item and one generic business rule engine parses and fills it in, so admins can add or edit request-type wording without touching script.
If no template is defined at all, both rules fall back to a plain variable (current.variables.Description for the description, current.request_item.u_task_short_description for the short description).
| |