issue with repeat values when auto generate a field within editable layer Form

98
0
2 weeks ago
MarkGambordella
New Contributor III

We are creating a tool that will be used to issue new addresses.  there are several fields that will auto populate within the editable form.  One of these fields is the unique ID given to each address (ADDR_PT_ID).  this unique value is generated from the Maximum number in the dataset that corresponds to the ADDR_PT_ID, then a plus 1 is added to next the next number in the series. ( example:  the last address entered in the attribute table had an ADDR_PT_ID of 150223, the form would then auto populate the next address that is being entered as 150224.)  the problem arises when 2 users are creating addresses at the same time within the same app.  It will issue the same ADDR_PT_ID for both users (ex. 150224 and 150224), this results in duplicate IDs for different address.  Code is below:

var adds = $featureset
for (var f in adds){
  var tots = Number(f.ADDR_PT_ID)
}
return max(tots)+1
 
Is there a way to force it to recognize that someone else is adding an address at the same time, and have it auto populate different ADDR_PT_IDs for each?  have it recognize that someone else is editing the address layer and has already pulled the max number of ADDR_PT_ID.  
0 Kudos
0 Replies