In this tutorial, I have explained how to fix the error, “The template language function ‘length’ expects its parameter to be an array or a string. The provided value is of type ‘Integer’“.
The template language function ‘length’ expects its parameter to be an array or a string
Recently, I was doing a Power Automate of flow example on how to auto generate column value using Power Automate or Flow in SharePoint.
There I was using an expression like the below, which was causing the issue.
length(triggerBody()?['ID'])
Basically, I was trying to get the length of the ID column value.
But it throws an error as,
Unable to process template language expressions in action ‘Initialize_variable’ inputs at line ‘1’ and column ‘10896’: ‘The template language function ‘length’ expects its parameter to be an array or a string. The provided value is of type ‘Integer’. Please see https://aka.ms/logicexpressions#length for usage details.’.
And the error looks like the below:

I was using the expression below:
![The provided value is of type Integer the execution of template action 'apply_to_each' failed: the result of the evaluation of 'foreach' expression '@triggeroutputs()?['body/resourcedata/responseid']' is of type 'integer'. the result must be a valid array.](https://i0.wp.com/www.spguides.com/wp-content/uploads/2020/08/The-provided-value-is-of-type-Integer-1024x309.png)
Here, I was trying to get the length of the ID list column, this is an integer column.
So, we need to convert to string to get the length of the ID column value.
In Power Automate or flow expression, we can convert int to string like below:
length(string(triggerBody()?['ID']))
The expression should look like the below:

This is how we can get the length in Power Automate or Flow.
This is how we can fix the error, ‘the function ‘length’ expects its parameter to be an array or a string. the provided value is of type ‘object’..
You may also like:
- Power Automate Concatenate String
- Power Automate save email attachment to SharePoint
- Power Automate Trigger Conditions
I am Bijay a Microsoft MVP (10 times – My MVP Profile) in SharePoint and have more than 17 years of expertise in SharePoint Online Office 365, SharePoint subscription edition, and SharePoint 2019/2016/2013. Currently working in my own venture TSInfo Technologies a SharePoint development, consulting, and training company. I also run the popular SharePoint website EnjoySharePoint.com
Struggled with similar problem for 2 days with the “add” function. You made my day, as your solution directed me to the simple fix for my issue. Thanks so much!