MaxStrueverWipro

How best to move an AFAttribute from one element to another location?

Discussion created by MaxStrueverWipro on Mar 1, 2012
Latest reply on Nov 4, 2013 by cmanhard

I am trying to use the AFSDK to move an attribute from one location in the AF Hierarchy to another. 
I tried getting a reference to the attribute in the original location, and adding it to the new element, but was given an exception telling me that the attribute already belongs to an element.  

 

 

 
AFAttribute attributeToMove;
AFElement TargetElement = AFDb.Elements["New target element path"];
//does not work
TargetElement.Attributes.Add(attributeToMove);

 

 

Should I just create a brand new attribute in the target element, and grab all the information from the old attribute, then delete the old attribute? 

 

That is the only option I can think of at this point, but just wanted to make sure there wasn't an easier way to do this. 

 

 

 

Thanks

Outcomes