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 Apps / Row number in Datavers...
Power Apps
Answered

Row number in Dataverse table.

(0) ShareShare
ReportReport
Posted on by 35

Hi everyone, 

I have model-driven application where users fill data's in main form (Table A) and in subrid form (Table B). There is a relation One to Many between these tables. Table A store documents and Table B stores lines of my documents. When users is adding lines in subrid I would like to have a row number of each lines in the document context. For example :

Table A ( Number, Description, Value ) -> Table B (Number - related field, Row number, Description lines, Value)

Table A (01/01/2022, "test", 1000) -> Table B (01/01/2022, 1, "test line 1", 500), Table B (01/01/2022, 2, "test line 2", 500 ).

In next new document the counter in Table B should start from 1. 

Is it possible to do it in dataverse or in model-driven form ?

 

Will be greatfull for any informations.

Regards, 

Maciej

 

I have the same question (0)
  • Verified answer
    Drew Poggemann Profile Picture
    9,287 Most Valuable Professional on at

    Hi @mdrapala ,

     

    The autonumber field will not be able to accomplish this approach because it is a global number across the entity so in your table B it would not reset each row which is not want you want.  Just wanted to identify why this would be out of consideration as an approach.

     

    The method I have used in the past here is the following.  This is not perfect because if you allow delete you will have gaps in your numbers and you might have to create a flow that will loop through the values and reset if needed when you delete a row.

     

    Approach:

    1. Table A - Add new whole number column that is called something like "Max Line".  When you create the record, default this value to 0.
    2. Table B - Add new whole number column that would be called "Line Number" or something like that.
    3. Create a real-time workflow on creation of record in Table B that will do the following:
      1. Set Line Number to Table A Max Line + 1
      2. Increment Table A Max Line column

    Again this will provide the functionality you need but it will have an edge case where if you delete a line in Table B you will have a gap and then maybe you could write a flow on the delete of the record from that table that would loop through all the lines and re-number which should be pretty easy to do.  Just make sure you run this with a max of 1 at a time so you don't have two running stepping on each other (i.e. if you delete multiple lines).

     

  • mdrapala Profile Picture
    35 on at

    Hi @dpoggemann,

    thank you for showing me a workaround for this case 🙂  I regret that in model-driven we don't have ootb function to count rows, but maybe in future Microsoft will improve it.

     

    Kindest Regards, 

    Maciej

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 Apps

#1
WarrenBelz Profile Picture

WarrenBelz 739 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard