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

4
  • Can you also add the order in which the calling the custom events from the Content Manager configuration?
    – Shiva
    Apr 2, 2019 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)? Apr 2, 2019 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, 2019 at 16:55
  • Updated the question.
    – Atila Sos
    Apr 3, 2019 at 11:26

1 Answer 1

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 :-)

2
  • 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, 2019 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). Apr 11, 2019 at 17:14

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.