Adding new element with unique ID value

Hi,

I'm new to AppSheet and trying to learn as much as possible in short time but found a small problem. I have an app which contains a number of data referred to locations (like typical POIs with name, address, lat/long). I allow adding new locations to the map with few required fields.
Even though my spreadsheet is organised by the ID's whenever new additions are made I'm able to use already existing ID's which then are multiplied in the database. Can you please suggest how to make the ID number predefined based on what's already added in the spreadsheet but incremented by 1?
(e.g. in spreadsheet there are already IDs from 1 to 17, when I add a new location the ID value in form is automatically set to 18).
Many thanks in advance.

Solved Solved
0 7 1,052
1 ACCEPTED SOLUTION

Actually you should try being clearer about your objectives and how to express them to get help; since no one has a cristal ball or telepathy powers to read your mind. You want to sort in a specific order, then you should state it as a requirement. 

What is your sorting criteria? Is it just which record was added after which? In this case sorting for example by a Timestamp is a better choice than using sequential numbers. 

However, if you still want to use sequential numbers as index, then I encourage you to read this guide:

https://www.googlecloudcommunity.com/gc/Tips-Tricks/Serial-Numbers-If-You-Must/m-p/286300 

View solution in original post

7 REPLIES 7

Hello and welcome to the community!

You should add a new column to your table, name it for example โ€œkeyโ€, make it hidden and set its Initial Value to: UNIQUEID(). 

Hi KJ,

Thanks for your answer but this did not resolve my problem.
As the column is tend to be hidden it won't be available in the adding new POI form - therefore won't be filled automatically and still the ID value that in the spreadsheet is already used may be used again (multiple times) to add new pin to the map.

OK. Go to your "ID" column, and put: UNIQUEID() in its initial value field. 

๐Ÿ™‚ Nice try but also doesn't help. In this case ID is unique but it doesn't resolve the issue that when I'm adding a new pin the unique value will be added to it. As I'd like to sort by a particular order I'm still unable to do it. After adding new pins they'll be reordering the whole list instead of being added at the bottom of it.

Actually you should try being clearer about your objectives and how to express them to get help; since no one has a cristal ball or telepathy powers to read your mind. You want to sort in a specific order, then you should state it as a requirement. 

What is your sorting criteria? Is it just which record was added after which? In this case sorting for example by a Timestamp is a better choice than using sequential numbers. 

However, if you still want to use sequential numbers as index, then I encourage you to read this guide:

https://www.googlecloudcommunity.com/gc/Tips-Tricks/Serial-Numbers-If-You-Must/m-p/286300 

I'm sorry, maybe I wasn't specific enough. I thought that the example written in original message was suggesting that.
Nonetheless the idea of using incremented MAX table value is good. Thank you very much

Take it easy my friend, nothing to be sorry for.. and welcome!

Top Labels in this Space