6

I'm trying to write an event that will basically append the TCM value to the end of the component name

this-is-my-componentname-1235

While for existing components this is easy enough during 'OnComponentSavePre', I've run into a roadblock for new components, as from what I can tell I can't obtain the Id until the 'TransactionCommitted' phase, at which point I can't impact the current component.

Is there any way for me to either obtain the Id prior to the 'TransactionCommitted' Phase, or a way for me to post commit go back and update the component title?

0

2 Answers 2

6

In the transaction committed phase you would have to call the Save method on the component, which would create a new major version. Unfortunately, this is the only way to do it as far as I know.

1
  • 1
    New items don't have an id until they're saved, so yeah, no easy way to do this on V1
    – Nuno Linhares
    Feb 26, 2016 at 20:55
1

As has been said, you need to save the item for it to get an Id. This means that somehow you will need to enforce a second write.

I don't see why you couldn't do this in the Transaction Committed phase. The component is saved, so you can read it anew, modify it and save it.

The only other possibility I can think of is workflow.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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