I have a logic app where i use a condition expression on to two variables, displayName
and accountName
.
Sometimes a variable will not exist. which will cause this error:
InvalidTemplate
Unable to process template language expressions for action 'Condition' at line '0' and column '0': 'The template language function 'contains' expects its first argument 'collection' to be a dictionary (object), an array or a string. The provided value is of type 'Null'.'.
How do i handle this error? I want the condition to treat the null value as if the variable is a empty string
Is it possible to write a expression thats like iff(accountName
is empty(), '', accountname
)?
You can do so by using coalesce() function.
I am using below given expressions to achieve this.
coalesce(variables('accountName'),'')
coalesce(variables('displayName'),'')
This works if one variable is not exist. Here I am only passing the value of account name but not display name.