Formula Syntax Error

Hi,
I'm trying to do something similar to an NVL or ISNULL, so check one field and if it's filled in, use it, if not, use a different field.
The field that I want to check first is results[*].properties.membership_tier_for_renewal
and the field that I would like to use if it's empty is results[*].properties.membership_level
The formula I used is:

{{#if results[*].properties.membership_tier_for_renewal}}
{{results[*].properties.membership_tier_for_renewal}}{{else}}
{{results[*].properties.membership_level}}{{/if}}

The error that i'm getting is:
Failed to generate field value from template: {{#if results[*].properties.membership_tier_for_renewal}}{{results[*].properties.membership_tier_for_renewal}}{{else}}{{results[*].properties.membership_level}}{{/if}}. Details: Parse error on line 1: {{#if results[*].propertie ------^ Expecting 'CLOSE_RAW_BLOCK', 'CLOSE', 'CLOSE_UNESCAPED', 'OPEN_SEXPR', 'CLOSE_SEXPR', 'ID', 'OPEN_BLOCK_PARAMS', 'STRING', 'NUMBER', 'BOOLEAN', 'UNDEFINED', 'NULL', 'DATA', 'SEP', got 'INVALID'.

Any help is appreciated.

Thanks.

Have you tried putting brackes around results[*].properties.membership_tier_for_renewal}}?
It would be results[*].properties.[membership_tier_for_renewal]}}

You can't use [*] because that indicates an array of many options to look at which the if block helper does not do. If this results array would only ever have 1 result, then I would either:

  1. Change your lookup response mapping from the prior step where I assume you are getting this results. If there would ever only be 1 result, make the response mapping just be data.0 = result. Then you won't have to deal with this array later.
  2. You can hardcode the position by just doing:
{{#if results[0].properties.membership_tier_for_renewal}}
{{results[0].properties.membership_tier_for_renewal}}{{else}}
{{results[0].properties.membership_level}}{{/if}}
  1. Additionally, if this results is coming from your inital export and all results should be treated as their own record, then set your path to records as results

Hey Tyler,

I tried option #2 that you listed below, but I'm getting the exact same error from that. But I reviewed # 1 again and was able to transpose the data so this fields are on the top level and that worked.
I am getting a separate error now that i'm troubleshooting. If i can't figure it out, i'll create a new topic here. Thanks for the help. This can be closed.

1 Like