
Announcements
Hello i have an interesting error i cant wrap my head around. I am trying to Add an Attachement to my sharepoint list throught a pen input in powerapps. Below is my error message.
Unable to process template language expressions in action 'File_Content' inputs at line '1' and column '7316': 'The template language expression 'dataUriToBinary(split(item(),'|')[1])' cannot be evaluated because array index '1' is outside bounds (0, 0) of array.
Hi @niklasjegg,
A split function will return an array. In your expression you are trying to retrieve the second item/part of that split array. However, the error suggests that the array has a range of 0,0. So, I guess it can't find your | character in one of the items and has no split result.
As an example I could reproduce this same error with the expression below. Hope that makes sense?
split('Lets split some text', '|')[1]
My suggestion would be to first check if the item actually contains a | character before you start using it for a split function. You can use indexof, equals and if functions for this.
Edit: forgot to add examples 😅
When | character is present
if(equals(indexOf('Lets split | some text', '|'), -1), 'Do Nothing', split('Lets split | some text', '|')[1])
When | character is not present
if(equals(indexOf('Lets split some text', '|'), -1), 'Do Nothing', split('Lets split some text', '|')[1])