SOLVED

Concatenate Fieldname into Expression

Brass Contributor

I have an Excel table with fields for Year1, Year2, Year3, Year4, Year5

I want to create a Sharepoint item in Power Automate for each.

 

 

I have created an array ( [1,2,3,4,5])

I have an apply to each item based on my array - Items(‘Apply_to_each_financial_year’)

I have a create item from my spreadsheet  - outputs('Get_a_row')?['body/Year1']

 

I would like the correct syntax so that the create item refers to the year number in the array, not just year 1

outputs('Get_a_row')?['body/YearItems(‘Apply_to_each_financial_year’) ']

 

I presume this is a concatenate of some sort, but I can't get the syntax

If I can get this syntax to work it would loop round and create an entry for all 5 years without needing to write 5 create item actions in the flow.

 

Many thanks in advance

4 Replies

@Geoffers Try using this expression if it works: 

 

@{concat('outputs(''Get_a_row'')?[''body/Year', item(), ''']')}

 


Please click Mark as Best Response & Like if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.

Thanks for replying
concat('outputs(''Get_a_row'')?[''body/Year', Items('Apply_to_each_financial_year'), ''']')

The expression is happy to process the concat but then doesn't evaluate the result - it just populates Sharepoint with the string. If I add the "@" and "{}" symbols I get an "invalid" error.

BTW - your concat was missing its closing bracket ;)
best response confirmed by Geoffers (Brass Contributor)
Solution
Hi All
For anyone who cares, the correct syntax is -
outputs('Get_a_row')?[concat('body/Year', Items('Apply_to_each_financial_year'))]

So the concat is only applied to the "Body/year" part of the statement. Encompassing the entire output statement results only in a string that isn't evaluated.

@Geoffers Great, glad you found the correct solution. Happy that you were able to figure out the correct expression based on my hint about using concat function.


Please click Mark as Best Response & Like if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.

1 best response

Accepted Solutions
best response confirmed by Geoffers (Brass Contributor)
Solution
Hi All
For anyone who cares, the correct syntax is -
outputs('Get_a_row')?[concat('body/Year', Items('Apply_to_each_financial_year'))]

So the concat is only applied to the "Body/year" part of the statement. Encompassing the entire output statement results only in a string that isn't evaluated.

View solution in original post