web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Converting array to in...
Power Automate
Unanswered

Converting array to integer

(1) ShareShare
ReportReport
Posted on by 216
I am trying to populate a lookup field in my SharePoint list with multiple values. I want to keep the values that are already there and add a new value to it.
To do this, I have appended the current values (Ids of the column) in an Apply to each like this:
I then use another Append to string variable to add the new value.
From there, I use another apply to each and apply a split to the string variable:
I use an append to array variable with 
int(items('Apply_to_each'))
So the steps look like this.
 
 
The array variable I add to my Update items. However, my array variable is showing up like this:
[" 182\n"," 181\n"," 186\n"] and it's saying not convertible to integer. 
 
What am I doing wrong here and is there a better way I could be achieving this?
Categories:
I have the same question (0)
  • rzaneti Profile Picture
    4,249 Super User 2025 Season 2 on at
    Hi,
     
    Did you try to use an array variable, rather than a string one, and then use the Append to array variable in your loops, rather than Append do string variable?
     
    If you need to work with strings for some reason, you will have to transform your individual arrays items (which are strings) into integers, and for that you will need to use an expression like this: int(trim(replace(uriComponent([your_item_here]), '%0A', '')))
     
    By using this expression, we are first removing the line break ('\n') by using the replace() method and then removing the blank space at the beginning by using the trim() method. As a final step, we are transforming the final string (which now must look like "182" or "181") into a number by using the int() method.
     
    To learn more about data types or text transformation in Power Automate, refer to these blog posts:
     
    Let me know if it works for you or if you need any additional help!
    -------------------------------------------------------------------------
    If this is the answer for your question, please mark the post as Solved.
    If this answer helps you in any way, please give it a like.
     
     
  • CAlvy Profile Picture
    216 on at
    Hi @rzaneti
     
    Thanks for your reply!
    So I needed this as an array so I could update my multi-select lookup column. I was following the answer in this post: 
    What I probably did wrong was not put in my Append to array variable
    {
    "Id":
    }
    I corrected this and ran the test again and it worked that time.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 525 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 324 Moderator

#3
abm abm Profile Picture

abm abm 232 Most Valuable Professional

Last 30 days Overall leaderboard