Support for Attribute rules in ArcGIS Online

53596
78
07-15-2019 03:27 PM
Status: Open
Yann-EricBoyeau
Frequent Contributor

At pro 2.4 ESRI implemented attributes rules at the file Geodatabase Level which is great.

It means that when you copy or move the file geodatabase, you copy or move the rules.

So if you upload this fgdb to AGOL, the rules are uploaded within the fgbd. 

Attribute rules are « able to travel » to AGOL.

 

At the moment these rules are not interpreted or implemented at the AGOL level.

The idea here is to have the rules interpreted and implemented in AGOL when publishing feature services from a rules enabled fgdb.

It would be great to have attributes rules fully implemented in ArcGIS Online.

This would allow users to have their own QC and field calculation in hosted feature layers and web apps !

(edited 2020-07-24 to improve this description)

78 Comments
Nick_Creedon

I see a lot of posts about this... Attribute Rules supported in ArcGIS Online. I know they have "Forms" in web maps and field maps, this workflow is not the most ideal when we have multiple maps with different layers being edited daily through Esri apps and in 3rd party apps. This functionality would be super helpful for those organizations that work completely in AGOL. It would also be extremely helpful if you could create the rules in ArcGIS Pro and the attribute rules would carry over into AGOL with the newly shared Hosted Feature Layer (Web Layer).

JamesBooth

I'm a bit surprised that this hasn't been addressed by now. I thought best practices recommended setting up your schema and any other backend configuration settings, like attribute rules, within ArcGIS Pro before publishing to a feature layer. Perhaps I was mistaken?

I'm hoping that all that work I put into developing working attribute rules has not been pointless, as ArcGIS Portal doesn't seem to recognize the rules. A relationship class I created between two feature classes is recognized, but not their attribute rules. My feature layers are being pulled from ArcGIS Server map services referencing data from an Enterprise SDE environment (SQL Server). The rules from my Pro document and FGDB did successfully transfer to my SDE layers. Just not pulled over when publishing to ArcGIS Portal. I realize this thread relates to ArcGIS Online, but I believe this applies to Portal as well. Any news updates on this farily common issue?

KevinMayall

We are trying to implement Cityworks with ArcGIS Online and each hosted feature layer needs to maintain a unique ID field as an asset number.  All I want is to auto-increment a user-defined field automatically, as features are created, in ArcGIS Online.

CalvinHarmin

@KevinMayall 
We have this frustration as well with AGOL hosted feature layers -- no ability to use a 'database sequence' type of integer auto-incrementing for the purposes of asset ID generation. There is an arcade expression that almost gets there by calculating the 'max' integer of the existing asset ID field. However, if more than one person is in the field (or office) adding new features, they will both be trying to save a new feature and both will have the same asset ID since in both cases the 'max' asset ID of the existing data is the same at the time they started created the new feature. This means one of them will 'lose' if the other saves first, and they have to cancel that feature creation and start over. 

Here is the arcade expression I've applied for my 'POLE' hosted feature layer with asset id field named 'POLE-ID'. Hopefully the rest is self-explanatory. I believe the original source of this arcade expression was from the Sign Management solution. I found the solution helpful as a starting point but went in a different direction since the solution has way more functions than I care about and I wanted to have my related SIGNS assets in a table format and not a point layer format. Anyway, I'm just sharing this example in case your use case doesn't have multiple editors at once, it might work for you.

 

var layerIndex = '0'  // PW_Pole is the layer reference '0' in the AGOL Hosted Feature Layer service; PW_SIGN layer reference is '1'
var idField = 'POLE_ID'
var idPrefix = 'POLE-'
var digits = 5

/*DO NOT CHANGE ANYTHING BELOW THIS LINE
-------------------------------------------------------------------------*/

function GenerateWildcards(digits, wildcard) {

  var wildcards = ''
  for (var i=0; i < digits; i++) {
    wildcards += wildcard
  }
  return wildcards
}

function GetNextId(layerIndex, idField, idPrefix, padding, sqlFilter) {
  // get the feature with the greatest assetid that matches the id pattern specified in the SQL statement.
  var assetid_features = Filter(FeatureSetById($datastore, layerIndex, [idField], false), sqlFilter)
  var max_assetid_feature = First(OrderBy(assetid_features, `${idField} DESC`))  

  // If no features match the pattern the featureset will be null, return the first assetid
  if(max_assetid_feature == null) {  
    return `${idPrefix}${Right(padding, Count(padding)-1)}1`
  }

  // when features do match the pattern calculate and return the next assetid  
  var max_assetid = max_assetid_feature[idField] 

  var next_assetid_number = Number(Replace(max_assetid, idPrefix, "")) + 1
  return `${idPrefix}${Text(next_assetid_number, padding)}`
}

// Define the edit context so the value is only calculated when the feature is created
if ($editContext.editType == "INSERT") {
  // return matching prefix pattern and get next value
  var wildcards = GenerateWildcards(digits, '_')
  var padding =  GenerateWildcards(digits, '0')
  if (idPrefix != '') {
    var sqlFilter = `${idField} LIKE '${idPrefix}${wildcards}' AND ${idField} NOT LIKE '%[^0-9]'`    
    GetNextId(layerIndex, idField, idPrefix, padding, sqlFilter)
  }

// return number id's only and get next value
  else {
    var sqlFilter = `${idField} NOT LIKE '%[^0-9.]%'`    
    GetNextId(idPrefix, padding, sqlFilter)
  }
}

else {
  return $feature[idField]
}
RichardLittlefield

For the auto incrementing IDs, I've seen creating a python script then using that in a Notebook in AGOL/Portal. Then you can schedule that in AGOL to run every hour or at whatever increment you want. This does use AGOL credits though. Just another work around to think about. Still doesn't fix attribute rules not being supported in AGOL.

CalvinHarmin

@RichardLittlefield

I could see that working for some use cases. In my case this would not be a solution for a custom asset ID field, as I have an hosted feature layer (Pole, point) that is related to another hosted feature layer (Sign, table) with the custom asset ID field being the key.

So the Pole must have an asset ID before a sign can be created. Or, in other words, an existing Pole feature must be selected, and there is an option to create a related sign record from that pole feature using the asset id field as the key. The field work includes taking pictures of the pole and selecting attributes, and then creating a sign asset attached to it and taking pictures and creating attributes for the sign, etc. It must be done right there in the field and can't (realistically) be accomplished after the fact, or it would require multiple field visits to the same location at another time after the notebook script has run.

OBJECTID-based asset id integer from an arcade expression also doesn't work since oid is not generated until the feature is submitted to AGOL. The arcade expression can't calculate after submission, it is calculated before.

wtfineberg

+1 to this idea. Attribute Rule Calculations would be immensely valuable in AGOL for our workflows.

LeviCecil

How is this still not implemented six years later?? We have a client who does all their work in AGOL/Field Maps, and they need incrementing IDs on their layers.