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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Get Last OID from SQL ...
Power Automate
Unanswered

Get Last OID from SQL and Increment The Variable by One

(1) ShareShare
ReportReport
Posted on by 2
I'm setting up a flow that will read rows from Google Sheets and write them to an ArcGIS SQL db. I need to find the last object ID and increment this value by one to write the new row into SQL. I cannot figure out how to make this work with for each loops. When I try to initialize a variable, it keeps telling me the Object ID is not a valid integer, yet Insert Row (V2) requires it to work. Here is what I have so far:
 
 
Categories:
I have the same question (0)
  • Michael E. Gernaey Profile Picture
    53,963 Moderator on at
    Hi
     
    So, unfortunately you aren't showing the Expression you have in the variable.
     
    Since to access the value, you need to use the Array access path from the Get Items above the variable initialize, where in the Loop, I have no doubt you are probably correctly accessing it because its easier, as its in the loop currentItem or Item() property, where you do not have that in the Variable.
     
    Please share your expression.
     
    You can use a compose, or a Filter Array etc, but its all based on how you sort for instance) in your Get Items, Using First, Last is your best bet as it will do what you want.
     
     
    So essentially, you can do a First(body/value of your get items), or Last same thing, but again it depends on your sort. If you didn't sort them so its the last one, then you have to either do a Select (and only grab that column) then sort that.
     
    Either of these will work
  • LC-21011721-0 Profile Picture
    2 on at
    Hi Mike, 
     
    Thanks! Do I need another connector here to add a Last() statement?
    variable.PNG
    getrows.PNG

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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Valantis Profile Picture

Valantis 391

#2
11manish Profile Picture

11manish 276

#3
David_MA Profile Picture

David_MA 256 Super User 2026 Season 1

Last 30 days Overall leaderboard