3

Read the following question which explains TCMs like tcm:x-xx-v0 are created when items are checked out.

However when Ive tested using a simple C# TBB:

log.Debug("Executing C# template");

Item item = package.GetByName(Package.ComponentName);
Component component = (Component)engine.GetObject(item);
var versions = component.GetVersions().Cast<Component>().OrderByDescending(v => v.RevisionDate);
var ids = string.Join(",", versions.Select(c => c.Id.ToString()).ToList());
var vs = string.Join(",", versions.Select(c => c.Id.Version).ToList());

log.Debug(ids);
log.Debug(vs);

And checked out a component I see the following in the Template Builder log:

Debugging was started in process 'TcmTemplateDebugHost' with id 18688
CSharpSourceTemplate: Executing C# template
CSharpSourceTemplate: tcm:346-403444-v2,tcm:346-403444,tcm:346-403444-v1
CSharpSourceTemplate: 2,-1,1

I'm assuming the TcmUri.ToString() strips the "-1" off, but even the Version isn't "0", its "-1" - which is inline with the API docs:

Either a non-negative version number or IdNull when version is not specified.

So at what point is a TCM like tcm:x-xx-v0 actually retrievable or exposed?

UPDATE Given Atila's comment below, I'll provide a little context - we've recently upgraded to DD4T 2 TBBs and we've noticed that the *Generate dynamic page" TBB will generate JSON with a TCM ending"v0" for components in presentations on the page that are checked out.

I wrote my smaller TBB to investigate what was going on.

UPDATE So its seems that if you get component versions via GetVersions() you're checked out component is version "-1" and a full TCM doesn't contain any version info.

However if you ask for a checked-out Component's Id directly (say adding log.Debug(component.Id.ToString()); to the above, the TCM will contain a "v0".

DD4T uses tcmComponent.Id.ToString(); which is why we where seeing the "v0" emitted into the JSON for a checked out component.

Is it odd that DD4T doesn't remove this given its not needed on the CD-side?

Cheers

2

But why would you want to retrieve such a version in the first place? What would be your use case? If an item is checked out, you can still read the item with its "versionless" uri and you will get it as such (checked-out (readonly)). Or to be more precise, you will get the last major version which was checked in. There's no need for explicitly reading the "checked-out version" by using "v0" for example.

I have seen errors thrown when a RenderComponentPresentation is called from Tom.Net for a checked-out Component. The error message would say something about "-v0". Additionally, I believe you can also encounter the v0 when working with Event Systems for saving items in the initiated phase.

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.