Compare Handlebar Help!
I am trying to compare a field (record.Form.Id) to a specific set of numbers. If its one of those numbers, its a BrokerageHouse, else NonBrokerageHouse. I'm struggling to get the syntax right since there are a fair amount of comparisons, and any help is greatly appreciated.
{{#if (or
(compare record.Form.Id '===' '314')
(compare record.Form.Id '===' '254')
(compare record.Form.Id '===' '253')
(compare record.Form.Id '===' '278')
(compare record.Form.Id '===' '277')
(compare record.Form.Id '===' '336')
(compare record.Form.Id '===' '334')
(compare record.Form.Id '===' '257')
(compare record.Form.Id '===' '256')
(compare record.Form.Id '===' '267')
(compare record.Form.Id '===' '268')
(compare record.Form.Id '===' '275')
(compare record.Form.Id '===' '274')
(compare record.Form.Id '===' '318')
(compare record.Form.Id '===' '288')
(compare record.Form.Id '===' '287')
(compare record.Form.Id '===' '237')
(compare record.Form.Id '===' '240')
(compare record.Form.Id '===' '272')
(compare record.Form.Id '===' '271')
)}}
BrokerageHouse
{{else}}
NonBrokerageHouse
{{/if}}
0
Comments
Hey Dave,
Note: Use Strict check only if you know the data coming is going to match the data type.
The structure of data, I assumed is as below:
To understand more about Compare with else check out our docs here
Hey Dave -
You may also want to try the #contains helper... It acts like a string search when you give it a literal.
For example try this in the playground
Context:
{
"id": 125,
"name": "Bob",
"age": 33
}
Formula:
{
{{#contains "123*546*556*125" id}}yes{{else}}no{{/contains}}
}
David Gollom brilliant!
Please sign in to leave a comment.