Skip to main content

Notifications

Community site session details

Community site session details

Session Id : SV6IzzQbNVe3CkJRft7IrT
Power Automate - Building Flows
Unanswered

Converting array to integer

Like (1) ShareShare
ReportReport
Posted on 26 Jul 2024 10:14:47 by 187
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?
  • CAlvy Profile Picture
    187 on 26 Jul 2024 at 14:42:30
    Converting array to integer
    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.
  • rzaneti Profile Picture
    3,820 Super User 2025 Season 1 on 26 Jul 2024 at 11:23:50
    Converting array to integer
    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.
     
     

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

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,668 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 66,004 Most Valuable Professional

Leaderboard