I have a 'case number' field in our hosted feature layer that serves as a human-readable unique identifier. I need to prevent duplicate values being entered in that field (our current process is to run a query nightly to identify any duplicate entries).
Is there a way to set a unique index on that field? Or any other ways to guarantee uniqueness of values as the values are being entered?
In a sort of worst case, is there a way to query the hosted feature layer before the new record (or edited record) is submitted? If the value exists, the user could be notified.
Solved! Go to Solution.
As an update on this thread, Esri recently added the ability to add a Unique Index on a field for a hosted feature layer. See the help document here: Manage hosted feature layers—ArcGIS Online Help | ArcGIS
Search for the section header Add a unique constraint to a field
Thank you for your suggestion. We already have GlobalIds in the table. the problem is that they are not 'human readable'. We need something that an Admin or field user can refer to when talking about the record. Current we use something like 'i am working on case number 17-0567'. We couldn't do that (as easily) if we were using guids.
We have a similar setup where we need to generate a GISCODE field for all individual tables across the entire DB. We have a small setup wherein we generate an alpha numeric code to ensure that there is no duplicate data/codes.
So you can take 3-4 characters from the table name and concatenate it with the ObjectID. ArcGIS will take care of the OBJECTID and will ensure that there is no duplicate data.
I hope this helps!
Are you able to create the values like 'TABLE_1' automatically, or are they created/entered by a manual process? Do you have a way to guarantee that they are unique?
If you are using enterprise database you can use triggers to automatically populate an auto incremental value as the new record is added.
In a database we can never save two tables with the same names and so the combination of the partial table name and the OBJECTID will always be unique. Obviously there are many such other logics that can be implemented based on your usability and requirement.
I hope this helps!
Using a database trigger would be my preferred alternative, but I am using a hosted feature service on AGOL. It's my understanding that we don't have the ability to set triggers within the AGOL database. Perhaps my understanding isn't correct?
Thanks for your suggestions.