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

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.

| improve this answer | |

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.