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 working on a flow in Power Automate to auto-generate column values using Power Automate.
There, I was using an expression like the one below, 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.’.
The error looks like the following:

I was using the expression below:

Here, I was trying to get the length of the ID list column; this is an integer column.
So, we need to convert it to a 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:
- adddays() in Power Automate
- The execution of template action ‘Switch’ failed
- Power Automate Concatenate Strings
- Power Automate Trigger Conditions

Hey! I’m Bijay Kumar, founder of SPGuides.com and a Microsoft Business Applications MVP (Power Automate, Power Apps). I launched this site in 2020 because I truly enjoy working with SharePoint, Power Platform, and SharePoint Framework (SPFx), and wanted to share that passion through step-by-step tutorials, guides, and training videos. My mission is to help you learn these technologies so you can utilize SharePoint, enhance productivity, and potentially build business solutions along the way.
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!