In my code I am invoking the CopyEvent while copying a component from one location to another. While copying I need to modify the content in the Destination Component.

I tried using the CopyEventArgs.CopiedObject which is allowing me to get the details of the copied object but is not allowing me to set or modify any of the details of the object.

How can I modify the component I am copying when the destination component is created?

  • 1
    Karthik, welcome to the Tridion Stack Exchange Site and thanks for this great question! I have updated your question slightly to provide additional clarification on what you are asking. If you disagree with my edits, please feel free to revert my changes. Apr 30 '13 at 4:47

At a guess (without testing) I think you need to:

  1. Copy the component
  2. Check out the copied component
  3. Make your changes
  4. Save and CheckIn your component

Since you're using an event, I assume you're using TOM.NET. You should get your functionality with something along these lines (untested code):

ItemFields fields = new ItemFields(Component.Content, Component.Schema);
XhtmlField myField = (XhtmlField)fields["MyField"];
myField.Value = "new value";
Component.Content = fields.ToXml();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.