cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Manny123
Helper III
Helper III

Power Apps Canvas App Gallery ID

Hi Team,

 

I have an event Power Apps Canvas App that uses a single SharePoint List as a data source.

Every month we have an team event where users can post questions etc.  At the end of the monthly event we clear the canvas app so its blank screen start for the next event.

The event organizers want to know if it is possible that  SharePoint or Power Apps can show unique ID number for each question post in the Power App Gallery? Also the first question post will need to be 1. The second question 2 etc.

I know SharePoint list stores ID for each record created. But as we have been deleting question posts by default the next question post will be number 621. I need it to show 1 in the Power App gallery.

 

Any help much appreciated.

2 ACCEPTED SOLUTIONS

Accepted Solutions
One
Resolver III
Resolver III

Hi @Manny123 ,

I am currently unable to test this so I am just free writing it, but hopefully it will help point you in the right direction.

you can set a label or textbox in your gallery to

ThisItem.ID

 But I would suggest setting a variable in your app OnStart to act as an ID:

// Variable = 'current number of rows in list' + 1
Set('VariableName', CountRows(ListName) + 1);

Then anytime a new record is added to the list you can just set the ID column as the value of the variable. 

Also, SharePoint's default ID column continues the count even if records are removed from the list. so if you clear the list, the next time you go to use it, the first record will start where the previous entries left off. That is why I suggest using the variable to count the current number of rows + 1 as the new entries ID. 

------------------------------------------------------------------------------------------------------------------------------
Please click "Accept as Solution" if this post answered your question so that it is helpful for people having similar questions. If you found this post helpful smack that Thumbs up button! Thanks!

View solution in original post

One
Resolver III
Resolver III

@Manny123,

Yes it will, if there are no records currently in the list then the CountRows() will set the variable to 0. but you are then adding 1 to that variable so the count will always start at 1. Keep in mind you might need to add ways to refresh the list in the app as new entries get added, otherwise you may end up with duplicates if someone submits twice without closing/reopening the app. 

View solution in original post

4 REPLIES 4
One
Resolver III
Resolver III

Hi @Manny123 ,

I am currently unable to test this so I am just free writing it, but hopefully it will help point you in the right direction.

you can set a label or textbox in your gallery to

ThisItem.ID

 But I would suggest setting a variable in your app OnStart to act as an ID:

// Variable = 'current number of rows in list' + 1
Set('VariableName', CountRows(ListName) + 1);

Then anytime a new record is added to the list you can just set the ID column as the value of the variable. 

Also, SharePoint's default ID column continues the count even if records are removed from the list. so if you clear the list, the next time you go to use it, the first record will start where the previous entries left off. That is why I suggest using the variable to count the current number of rows + 1 as the new entries ID. 

------------------------------------------------------------------------------------------------------------------------------
Please click "Accept as Solution" if this post answered your question so that it is helpful for people having similar questions. If you found this post helpful smack that Thumbs up button! Thanks!

Manny123
Helper III
Helper III

Hi One,

Thanks for the response.  Will the solution you mentioned above make sure the Gallery will always start with ID 1 ?

 

One
Resolver III
Resolver III

@Manny123,

Yes it will, if there are no records currently in the list then the CountRows() will set the variable to 0. but you are then adding 1 to that variable so the count will always start at 1. Keep in mind you might need to add ways to refresh the list in the app as new entries get added, otherwise you may end up with duplicates if someone submits twice without closing/reopening the app. 

Drrickryp
Super User
Super User

@Manny123 

This question comes up repeatedly in the forum.  It is a basic principle that the ID be unique, usually sequential and never reused.  From the data base standpoint, this is important when relationships are created between tables. Otherwise, the data in a "child" table will be orphaned if the "parent" is deleted.

As a good practice, it is probably better to add a column for archiving data rather than deleting it. and filtering out the archived or inactive data.

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on June 15, 2022 at 8am PDT.

PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

Top Solution Authors
Top Kudoed Authors
Users online (1,749)