Hi!
I have a question about using action templates and referring to custom fields on an event logging form.
TLDR: Is there an easy way to get the value and/or shortCode from a specific customField, either by making VTLs in substitution keywords, or directly in an action template? I’m lookint for something similar to how visibility expressions can refer to a custom fields, and if possible how to get a list from multi-select fields.
Some context:
Today a lot of time is spent on copy-paste from Assyst to Outlook when our IT users have to send email from certain postboxes, such as when comunicating with certain suppliers.
We want to recude time spent on copy-paste from Assyst by pre populating most or all of the email from data already entered into an event.
In this effort, we want to make action templates that create the emails for easy copy-paste into Outlook, and this template then needs to extract some values from a select set of custom fields. The desired outcome would be a reusable substitution keyword to insert into existing templates, or simple extended keyword notation snipets to add to existing templates.
The wiki has some details on how to get a general overview of all the custom fields on an event form by iterating over all the values using $new.event.webCustomPropertyValues
, but there does not seem to be any examples of referring to values from specific custom fields.
I’ve made a macro that uses this logic to then filter on shortCode to only return the values from desired custom fields (this substitution keyword is a work in progress as it does not have logic to properly display multi-select fields).
#macro(getCustomFieldValueByShortCode $customFields $desiredShortCode)
#set($found = false)
#foreach($field in $customFields)
#if($field.parentWebCustomPropertyDefinition.shortCode == $desiredShortCode)
#showCustomValue($field)
#set($found = true)
#break
#end
#end
#if(!$found)
Field not found
#end
#end
#getCustomFieldValueByShortCode($new.event.webCustomPropertyValues "MY_SHORTCODE")
While this might be the approach for a more generalized solution if I could get the multi-select fields to work, currently it feels a bit overengineered. (There are also the design limitations imposed, as the macro itself can’t be used from the action template if it’s stored in a substitution keyword, meaning the macro would have to be replicated and maintained in each action template.)
With this in mind, it feels like there might be something basic I’ve overlooked when it comes to refering to the value of custom fields, which might even make multi-select fields easer to refert to aswell.
Is it possible to make substitution keywords refer to the value of a custom field in the same way visibility expressions are made with $new.event.W("MY_SHORTCODE")
?
If the macro approach is the best way forward, does anyone have any pointers or examples of dealing with multi-select fields?