5

I have a piece of Event System code which used to work fine on 2013 SP1, but when upgraded to Web 8.5 throws the following error:

The item tcm:X-Y-16-v0 does not exist.

Event Viewer:

enter image description here

The original code was simply logging the subject and action (Component's ID, path, etc.), but here is a simplified version below which also results in a said error:

EventSystem.SubscribeAsync<Component, SaveEventArgs>(OnComponentSavePost, EventPhases.TransactionCommitted);

private void OnComponentSavePost(Component component, SaveEventArgs args, EventPhases phases)
{
    Log(component.Path);
}

Looking at the documentation I can't find any reference as to why this would be happening, more specifically, about any underlying changes to the Event System / CM kernel. Any ideas?

Update

It's a fresh CM installation, there is no workflow and this is the only ES registered. I even stripped the code to the point that the only thing remaining in the configured dll is the code above. The error is thrown for both new and existing Components.

When remote debugging the code, only a couple of properties are available, the ID being a v0 (see below).

enter image description here

Update 2

I have tested with Subscribe() (+ transaction committed) and the difference is that now I don't get an error in EV, but instead a warning, however the handler code fails nonetheless. The properties are still unavailable when remote debugging.

enter image description here

  • Can you also add the order in which the calling the custom events from the Content Manager configuration? – Shiva Apr 2 at 15:06
  • Also - can you confirm no workflow and if this is for a new component or a component update (if the former, does it throw the same exception with an update)? – Dylan .. Mark Saunders Apr 2 at 15:13
  • Good point on the workflow as well. As a best practice, I would also prefer to use component.Id.GetVersionlessUri() in my code, since it is an asynchronous call. There are some changes under the hood but will wait for your updates to your question. – Shiva Apr 2 at 16:55
  • Updated the question. – Atila Sos Apr 3 at 11:26
5

I think the problem lies in the fact that your event handler is asynchronous (and you're subscribing to the TransactionCommitted phase).

A Save action normally happens on the dynamic version (v0) of an item. So, the -v0 in the TCM URI is no surprise.

However, if you do a typical save-and-close/checkin transaction, the check-in action typically results in the dynamic version being removed (it becomes the latest checked-in version).

Since you're (asynchronously) subscribing to the TransactionCommitted phase (which is always async, BTW; no need to also do SubscribeAsync for that phase), your event handler always triggers after the item has been saved and checked-in, so the dynamic version no longer exists (but it was the subject of the event).

Don't ask me how this could have worked in 2013 SP1, though :-)

  • Updated the question with additional findings for future reference. It seems that it's impossible to get the properties without (re)loading the component, so that's the route we will take. – Atila Sos Apr 11 at 13:49
  • For clarity: as mentioned, the TransactionCommitted phase is always asynchronous, so using Subscribe instead of SubscribeAsync won’t solve anything. Indeed, you will have to force load the latest checked-in version instead of the dynamic version (which no longer exists). – Rick Pannekoek Apr 11 at 17:14

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.