I created a log table in a file geodatabase. (Just my playground for right now). In this log table I want to keep track of the type of edit done to my feature classes, the name of the feature class, date, username, objectid and globalid in the feature. I have gotten all but one piece of the puzzle, the username. Here is my code below:
return {
"edit": [
{
"className": "Logs",
"adds": [{
"attributes": {"editType": $editContext.editType,
#For Each Attribute Rule Put in Feature Class Name Below
"fclassName": "VA_SouthParcels",
"Date": Date(),
"fclass_GlobalID": $feature.GlobalID,
"fclassObjectID": $feature.objectid } }]
}
]
}
I have looked the documentation for the ArcGIS Arcade functions of GetUser, however I can't quite get it to work, any help would be appreciated.
Thanks!
Solved! Go to Solution.
I haven't worked with GetUser() yet, but you should be able to do something like this
var user = GetUser($featureSet)
if(!IsEmpty(user)) {
user = user.username
}
In your FGDB, you won't have success with this, because
When no user is associated with the workspace, such as a file geodatabase, an empty string will be returned.
You could try turning on Editor Tracking, and then use the last_edited_user field:
var user = $feature.last_edited_user
I haven't worked with GetUser() yet, but you should be able to do something like this
var user = GetUser($featureSet)
if(!IsEmpty(user)) {
user = user.username
}
In your FGDB, you won't have success with this, because
When no user is associated with the workspace, such as a file geodatabase, an empty string will be returned.
You could try turning on Editor Tracking, and then use the last_edited_user field:
var user = $feature.last_edited_user
So since most of my layers have editor tracking enabled I modified that a little bit, and used this.
return {
"edit": [
{
"className": "Logs",
"adds": [{
"attributes": {"editType": $editContext.editType,
"fclassName": "VA_SouthParcels",
"Date": Date(),
"User":$feature.last_edited_user,
"fclass_GlobalID": $feature.GlobalID,
"fclassObjectID": $feature.objectid } }]
}
]
}
Which is nice because it even allows me to see if a user has deleted an item.
Thanks again.