4

I am having a difficult time getting a list of all versions of a Component.

When I run my code I get the error:

Error 9 foreach statement cannot operate on variables of type 'Tridion.ContentManager.CoreService.Client.FullVersionInfo' because 'Tridion.ContentManager.CoreService.Client.FullVersionInfo' does not contain a public definition for 'GetEnumerator' C:\SYSTFS_WEB_CONTENT_MGMT\CoreService_List_All_Versions\CoreService_List_All_Versions\Program.cs 166 13 CoreService_List_All_Versions

Here is my code:

string arycomp = "tcm:6-19764";
VersionsFilterData versionfilter = new VersionsFilterData();
VersionedItemData versionlist = (VersionedItemData)client.Read(arycomp, new ReadOptions());

var fulverinfo = (FullVersionInfo)versionlist.VersionInfo;
foreach (VersionedItemData allvinfo in fulverinfo)
{
    Console.WriteLine(versionlist.Title + "  " + fulverinfo.Version);
}

1 Answer 1

9

You should be able to get all versions like this:

    VersionsFilterData versionsFilter = new VersionsFilterData();
    XElement listOfVersions = client.GetListXml("(your tcm uri)", versionsFilter);
    foreach (var versionNode in listOfVersions.Descendants())
    {
        var versionID = versionNode .Attribute("ID");
    }

Note: You should use GetListXml, because GetList is not supported with this filter in Tridion 2011 (it might be in Tridion 2013, not sure about that).

With the XML you get, you'll be able to list all different versions of your object.

3
  • That did it. Yes, I was getting an error when trying to use client.GetList.
    – BryanD
    Commented Nov 15, 2013 at 17:28
  • Please accept the answer to help others in the future with the same challenge.
    – Nuno Linhares
    Commented Nov 15, 2013 at 18:46
  • That filter worked fine for me in 2013 - see tridion.stackexchange.com/a/3458/129 Commented Nov 15, 2013 at 19:26

Your Answer

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

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