I'm having issues creating a Constraint rule that checks whether a value exists within an array. These arrays will define whether or not the features can be edited by the user if they have a matching group/key to the owner field in the table.
The issue is that when passing the owner value from the feature class table, to the object, to grab the correct array of users, the attribute rule will not save and errors out saying that it cannot find the field. However, it will pass debugging using Console() within the Arcade editor window.
It will also work if the owner value is hard coded to grab the correct array (i.e. var array1 = partners['partner2'];). But will not work when that value is passed in a variable.
Has anyone else seen any issues around these topics setting up attribute rules?
var partners = Dictionary(
'partner1', ["user1", "user2"],
'partner2', ["user5", "user4"])
// Get currently logged in user
var userInfo = getUser().username;
// Get the "partner" value of the currently edited feature
var featureDataOwner = Replace($feature.DataOwner, ' ', ''); //theres sometimes spaces in the feature class table
var array1 = partners[featureDataOwner];
Console(userInfo)
Console(featureDataOwner)
Console(array1)
if (Includes(array1, userInfo)) return true
return false
Solved! Go to Solution.
Does it work if you insert this after line 9?
// check if the DataOwner is included in the dictionary
if(!HasKey(partners, featureDataOwner)) return false
Does it work if you insert this after line 9?
// check if the DataOwner is included in the dictionary
if(!HasKey(partners, featureDataOwner)) return false
It appears that it is working with that. Thank you!