InvalidTemplate Unable to process template language expressions in action…
- User
InvalidTemplate Unable to process template language expressions in action 'Gerar_Iniciais' inputs at line '0' and column '0': 'The template language expression 'if( empty(trim(variables('NomeRemetente'))), 'ZZ', concat( substring(first(split(trim(variables('NomeRemetente')), ' '))?[0], 0, 1), substring(last(split(trim(variables('NomeRemetente')), ' '))?[0], 0, 1) ) )' cannot be evaluated because property '0' cannot be selected. Property selection is not supported on values of type 'String'. Please see https://aka.ms/logicexpressions for usage details.'.
this is in microsoft power automate.
Assistant
The error you're encountering in Microsoft Power Automate is related to how you're trying to access array elements in your expression. The issue is with the array indexing syntax (
?[0]) being used on string values rather than arrays.Here's the corrected expression for your "Gerar_Iniciais" action:
if( empty(trim(variables('NomeRemetente'))), 'ZZ', concat( substring(first(split(trim(variables('NomeRemetente')), ' ')), 0, 1), substring(last(split(trim(variables('NomeRemetente')), ' ')), 0, 1) ) )Key changes:
- Removed the
?[0]array indexing - this isn't needed becausefirst()andlast()already return the first and last elements respectively - The
split()function returns an array, andfirst()/last()return the array elements directly
This expression will:
- Check if the 'NomeRemetente' variable is empty or whitespace
- If empty, return 'ZZ'
- If not empty, return the first letter of the first word and first letter of the last word concatenated together
For example, if 'NomeRemetente' is "John Doe", it will return "JD". If empty, it returns "ZZ".
- Removed the
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.