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 / Retrieve Dataverse row...
Power Automate
Answered

Retrieve Dataverse row count (& use it) without "for each"

(1) ShareShare
ReportReport
Posted on by

I have a flow which adds a new row to a dataverse table called "Projects."

I need to populate one of the new fields in the Projects table with the next available incremental number from the column "Master Project #"

I can retrieve the max number in the column "Master Project #" by using "List Rows" and sorting by the column in descending order & using a row count of 1.

My trouble is that I then need to insert this number into the "new row" step without turning it into a "for each" step.

Is there a better way to retrieve and use the highest number in the "Master Project #" column plus one?

Categories:
I have the same question (0)
  • abm abm Profile Picture
    32,865 Most Valuable Professional on at

    Hi @BertP 

     

    Yes you can specify the index try the below

     

    image.png

     

    outputs('List_rows')?['body/value']?[0]?['name']

     

     

    Note: When you use "List Rows" and sorting by the column in descending order & using a row count of 1. This will return the latest record you created. So better to add another filter query to extend using the  incremental number column not equal to zero or something. This will give you the second last record not the very latest record. Not sure this is the logic you want but I just want to mention that and it may be helpful.

     

     

     

  • BertP Profile Picture
    on at

    thx @abm 

     

    I'm not sure I explained the difficulty well enough. I am trying to retrieve the max value (whole number) of the column "Master Project #" plus 1 in a way that I can use a single number output. My problem is that when I put in any references to the "List Rows" step, PA creates a "for each" step. I can't have a "for each" step because the flow ultimately will only be adding a single record/row (it depends on a single row JSON output from powerapps for adding a single row).

     

    I tried the code you had above, but receive the following error: " 'outputs('List_Master_Project_Number')?['body']?[0]?['name']' cannot be evaluated because property '0' cannot be selected. Object properties can only be selected by names."

  • abm abm Profile Picture
    32,865 Most Valuable Professional on at

    Hi @BertP 

     

    Could you post a screenshot of your flow please? Since your using the List rows with row count 1 it will always put the loop even though it contains one record hence I suggested the expression. 

     

    Is here 'name' is your column, which is your incremental column?

     

    outputs('List_Master_Project_Number')?['body']?[0]?['name']' 

     

    You mentioned have a "for each" step because the flow ultimately will only be adding a single record/row (it depends on a single row JSON output from powerapps for adding a single row).

     

    Could you please explain the above?

     

    outputs('List_Master_Project_Number')?['body']?[0]?['here replace your incremental column']' 

     

     

    Thanks

  • Verified answer
    BertP Profile Picture
    on at

    Thank you so much @abm 

     

    After searching around, I seem to have found the right syntax, which was as follows:

    @{outputs('List_Master_Project_Number')['body']['value'][0]['cra6a_masterproject']}

     

    Thanks so much for setting me on the right path!

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