Given a WorkItem ID (e.g. "tcm:x-y-131200"), what is the proper way to get the workflow version of the item (component) in TOM.NET framework?

The following does not seem to return the workflow version. The compUri (Line 3) returns the non-workflow version number, and consequently the component (Line 4) is not the workflow version of the item.

TcmUri workItemUri = new TcmUri(workItemId);
WorkItem workItem = new WorkItem(workItemUri, new Session());
TcmUri compUri = workItem.Subject.Id;
Component component = (Component)session.GetObject(compUri);

It was previously done successfully in a Process Definition VBScript using the following:

Dim oComp
Set oComp = CurrentWorkItem.GetItem(1)
Dim oCompEdit
Set oCompEdit = TDSE.GetObject(oComp.ID, 2)
  • 1
    BTW, TOM.NET is not a supported API for workflow activities. Either use COM or CoreService (if release >= 2011)
    – Nuno Linhares
    Mar 29 '13 at 8:35
  • Also it usually isn't a good idea to create a new Session object yourself. This is most of the time an indication that you are trying to use the TOM.NET API in a location where it is not supposed to be used. If you are in Template code you could for instance get the Session through engine.GetSession() and in the event system through subject.Session. Mar 29 '13 at 8:46
  • 1
    I meant... use COM for Tridion 2009 or earlier and use CoreService for Tridion 2011 or later.
    – Nuno Linhares
    Mar 29 '13 at 8:51
  • Thank you, @NunoLinhares and @BartKoopman. The farthest I get with CoreServiceClient is in getting the WorkItemData.Subject (which is of LinkToVersionedItemData type) value. It looks like its IdRef and Title property is still showing the non-workflow version values.
    – libpcap
    Mar 29 '13 at 23:25

You don't need to read the item in this case, you can just use the Subject property:

TcmUri workItemUri = new TcmUri(workItemId);
WorkItem workItem = new WorkItem(workItemUri, new Session());
Component component = (Component) workItem.Subject;

The Component will be read just in time (JIT) as soon as you access some of its properties.

  • I tested getting the Subject property directly, unfortunately it is returning the non-workflow version of the component.
    – libpcap
    Apr 4 '13 at 16:26
  • @Arif You should be the performer of the current activity Apr 5 '13 at 6:28

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.