Set edit permission by attribute

739
1
07-27-2020 07:08 AM
JohannesLindner
MVP Frequent Contributor

We want to incorporate flood protection lines (dykes and walls) into our geodatabase (sde).

Our requirements:

  • These lines are written into bylaws in semi regular intervals.
  • The different versions (e.g. bylaw 2015, bylaw 2017) have to be reproducible.
  • Only the newest version can be edited, old versions must not be editable.
  • One and only one feature class. We don't want a feature class for every version, we don't want to export old versions.

My idea:

  • Include a field describing the version, make it depending on a coded value domain.
  • Different versions can be reproduced with views or definition queries.
  • When the latest version is written into a bylaw, create a new coded value, copy all features from the last version and change the version field. We can do this manually or create a tool.
  • Somehow forbid users from editing old versions.

Problems:

  • I could use an Attribute Rule to forbid editing old versions. But we haven't all switched to Pro yet, and AR make the feature class inaccessible in ArcMap. Is there another way to set edit permissions by attribute?
  • If I created a constraint AR with this code, triggered on insert, update, and delete:

    if($feature.Version=='Edit') {

      return True

    }

    return False

    It works with responsible users, but an irresponsible user could still change the value of Version to 'Edit' and edit the feature. They can't change the value back to the original version, so it's the equivalent of deleting the feature from the version. Also, with this code I have to disable the rule to change all 'Edit' features to a new uneditable version.
    Is there a way to circumvent these caveats?

Have a great day!
Johannes
0 Kudos
1 Reply
JohannesLindner
MVP Frequent Contributor

I found out about the Arcade global variable $originalFeature, which solves part of the second question:

// Allow changing the Version from Null to "Edit".
// This also allows setting the default value of Version to "Edit".
if(IsEmpty($originalFeature.Version) && $feature.Version=="Edit") {
  return True
}

// Allow changes to the "Edit" version.
if($originalFeature.Version=="Edit" && $feature.Version=="Edit") {
  return True
}

// Forbid everything else.
return False‍‍‍‍‍‍‍‍‍‍‍‍‍

With this code, users can't edit old versions. I still have to disable the rule to change the edit version into an uneditable version, but that has to be done quite rarely, so that's fine.

That leaves only the first question: Is there a way to do something like this without using Attribute Rules?


Have a great day!
Johannes
0 Kudos