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 / 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,928 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

Forum hierarchy changes are complete!

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

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Automate

#1
trice602 Profile Picture

trice602 339 Super User 2026 Season 1

#1
trice602 Profile Picture

trice602 339 Super User 2026 Season 1

#3
David_MA Profile Picture

David_MA 270 Super User 2026 Season 1

Last 30 days Overall leaderboard