Attribute rule problem with feature layer with attachment

06-09-2020 04:20 AM
New Contributor

Hi there, 

I have an issue with very simple (as i hoped) attribute rule, which should calculate number to a new feature. The number should be just one higher than maximal value found in the attribute. Here is my arcade: 

if ($feature.created_date != $feature.last_edited_date&&$feature.last_edited_user!="GIS") return $feature.cislo
var stanoviska = FeatureSetByName($datastore,'gisdata_sde.gis.UUP_zavazna_stanoviska_p',['cislo'], true)
var max_cislo = Max(stanoviska, 'cislo')
return ++max_cislo 

Funny thing. Everything seems okay, when i draw new feature in ArcGIS Pro it calculates value for field "cislo" well (just one higher). But when I draw new feature in Web App (from WebAppBuilder) using both Edit or smart editor widget the value in field "cislo" counts +2. I found out that the rule works well when the feature class doesn't have attachments but I need to work with FC with attachments. Is there any solution for this issue? It's kind of driving me crazy. 

Data are stored in SDE geodatabase as polygon feature class with attachments enabled and is published as service to arcgis server 10.7.1 (federated with portal). And attribute cislo is type of short integer (i also tried long integer and text). 

Every help is appreciated.



0 Kudos
3 Replies
Esri Esteemed Contributor

Hi Jana Košábková ,

In this specific case I would recommend to contact Esri Support to have them check what is happening. I have not seen this behavior before, and it almost looks like two requests are made when using a WAB.

I am also wondering why you don't make use of a database sequence: Create Database Sequence—Data Management toolbox | Documentation  then you can use Arcade to get the next number from the sequence. In this link you can see how it is used in combination with the NextSequenceValue function Attribute rule script expression examples—Geodatabases | Documentation 

0 Kudos
New Contributor III

Hello Xander,

well, I'll try to contact our local technical support. Hopefully someone will help me. 

I also tried database sequence and it worked well until we found out that when someone delete last feature with a specific number (555 for example), next drawn feature will get next number 556 (not 555 as we need). We just need complete numeric serie without gaps. If you have any other idea how to solve this problem, I'd be happy. 



0 Kudos
Esri Esteemed Contributor

Hi Administrátor Jihlava ,

Thanks for clarifying that you need to have a continuous range of values. It is important to realice that your current Arcade expression will not do that. It will take the highest number and take the next number. If any intermediate value will be deleted this will remain a gap. To get the first available number is to use something like this (I did not test it so it probably will need some tweaking):

// use any additional  logic before this
var stanoviska = OrderBy(FeatureSetByName($datastore,'gisdata_sde.gis.UUP_zavazna_stanoviska_p',['cislo'], true), 'cislo ASC');

var i = 1; // specify where the cislo code starts, I assumed 1
for (var f in stanoviska) {
    cislo = f.cislo;
    if (cislo > i ) {
        return i;
0 Kudos