Hi,
I have an array variable that's dynamically populated with strings at runtime (see below). The length of the array is unknown.
When accessing the array I'd like to check that the array element exists/ is within the bounds of the array before accessing and using it.
How do I safely access an array?
Here's an example of what I've tried already:
if(greaterOrEquals(length(variables('Categories')), 4),variables('Categories')[3], null)
The array has the following elements: "Unified Interface", "deprecated", "legacy web client"
I would expect the following:
length to return 3
greaterOrEquals statement to result in false
The first return value isn't evaluated and the second return value is used.
However this is the error I'm currently receiving:
InvalidTemplate. Unable to process template language expressions in action '~' inputs at line '1' and column '2725': 'The template language expression 'if(greaterOrEquals(length(variables('Categories')), 4),variables('Categories')[3], null)' cannot be evaluated because array index '3' is outside bounds (0, 2) of array. Please see https://aka.ms/logicexpressions for usage details.'.