Select to view content in your preferred language

[Attribute Rules, Arcade] Copying Feature to new Feature Class when deleting the Feature

2699
9
Jump to solution
11-08-2022 12:43 AM
StefanAngerer
Regular Contributor

Hi everybody,

I am currently trying to create an attribute rule that helps me to save a features data to an "archive" feature class when deleting that specific feature. I thought this would be possible with the new "edit" keyword but somehow my arcade code isn't working how i expect it to. Has anyone an idea what could be the problem?

Settings:

Attribute-Rule - Calculation

Update behaviour - Checked Deleting Box

Code:

return {
'edit': [{
'className': 'ArchiveFeatureClass',
'adds': [{
'attributes': {
... 'attributeIWantToCopy': $feature.attributeIWantToCopy...
},
'geometry': Geometry($feature)
}]
}]
}

PS: In this case my archive feature class has the same fields like the class from which I want to copy data when deleting a feature.

0 Kudos
1 Solution

Accepted Solutions
JohannesLindner
MVP Frequent Contributor

The rule works perfectly for me.

What's the problem? Doesn't it allow you to save the rule? Does deleting a feature give an error (screenshot please)? Can you delete a feature but it isn't copied? Something else?

 

Things to check:

  • You have to check the "exclude from application evaluation" checkbox
  • The field for the rule should be empty
  • for className, you have to use the complete name of the archive class. If you're working in an enterprise gdb, this is "Databasename.DataOwner.TableName"
  • Obviously, make sure that the field names are correct

Have a great day!
Johannes

View solution in original post

9 Replies
StefanAngerer
Regular Contributor

So by now i managed to copy some data when deleting a feature. I had to remove object_id, global_id and change some z-value settings in my archive feature class. However I am now having the problem that the copied feature is not displayed when i activate the archive feature class. The Behaviour is that I can select a copied feature, jump to the point where the old feature was with the Zoom-To Function but there I am not able to see a feature, even though it certainly jumped to the right place. I will keep you guys posted if I manage to solve the problem! 

0 Kudos
JohannesLindner
MVP Frequent Contributor

Make sure you have the correct geometry (especially z and m values). Make sure that your symbology shows all features.


Have a great day!
Johannes
0 Kudos
BrianRosa
New Contributor

Hi Stefan,

I am creating a similar rule to copy a feature into another table after updating a field. Can you explain more what you did with the z-value settings for your archive feature class? My issue is that the feature class I am copying to is not Z enabled, but the features I am copying from are. So I'm consistently receiving the "Geometry cannot have Z-values" error. Thanks!

0 Kudos
JohannesLindner
MVP Frequent Contributor

The rule works perfectly for me.

What's the problem? Doesn't it allow you to save the rule? Does deleting a feature give an error (screenshot please)? Can you delete a feature but it isn't copied? Something else?

 

Things to check:

  • You have to check the "exclude from application evaluation" checkbox
  • The field for the rule should be empty
  • for className, you have to use the complete name of the archive class. If you're working in an enterprise gdb, this is "Databasename.DataOwner.TableName"
  • Obviously, make sure that the field names are correct

Have a great day!
Johannes
StefanAngerer
Regular Contributor

So after some trying here and there and not changing anything on the rule or on the rule-settings. I now am abel to see my features. Seems like I only hade some issues as I tried to also copy the Object_ID and Global_ID. So thats probably the only thing we can learn from this topic -> When copying data to a new feature class -> make sure to not try to copy global or object id. Thanks!

0 Kudos
LyonMNGIS
Frequent Contributor

Hello,

I was not able to get this script to work to copy data from my "MasterData" layer to my "RetiredData" layer.  Both layers are in a single map and File Geodatabase.  I read through Johannes's notes and verified that I am excluding the rule from attribute evaluation, the field name of the rule is empty, and the field names match.

Thoughts?

return {
'edit': [{
'className': 'RetiredData',
'adds': [{
'attributes': {'ID': $feature.ID
},
'geometry': Geometry($feature)
}]
}]
}

*note ID is the name of a text attribute.

0 Kudos
StefanAngerer
Regular Contributor

Hi @LyonMNGIS ,

as for the return statement I don't see any problems (but I'm not an expert), could it be that you have confused the field name or the alias of the attribute ID, I've stumbled over that before. ah and if your id field is an object or global id the copy doesn't work either. see the message i wrote about it above

LyonMNGIS
Frequent Contributor

Stephan,

Thank you for your help.  I was missing the global ID!

The next step I have it to see if I can copy all of the attributes without needing to explicitly define each one as my dataset has 40_ attributes!

return {
'edit': [{
'className': 'RetiredData',
'adds': [{
'attributes': {ANUMBER : ANUMBER, CTU_NAME : CTU_NAME, STATE_CODE : STATE_CODE, COUNTRY : COUNTRY },
'geometry': Geometry($feature)
}]
}]
}

 

 

0 Kudos
LorindaGilbert
Frequent Contributor

Hi,

Has anyone tried this AR technique with taking the deleted feature that has a code to search on "class = D" but instead of copying the geometry and attributes, only copy the attributes to another table and then delete the geometry?  Our original data was in a flat file format in oracle, now migrating to a pro project and using as many attribute rules as possible.  The original deleted table has no spatial reference, so we will be just moving the attributes to it.  I'd like to do an AR, but do have other ideas with a geoprocessing data model or using a script in FME.

Thanks,

Lorinda

0 Kudos