This article describes the methods used to collect all versions of a given Item.
public static IswItems GetAllVersionsOfItem(IswItem item)
{
//Store all the versions.
IswItems allVersions = SWConnection.Instance.Broker.Lists.NewItemList();
//Get the first version. It is easiest to start there.
IswItem firstVersion = SWConnection.Instance.Broker.GetItem(item.AncestorHandle);
AddAllVersionToList(firstVersion, allVersions);
return allVersions;
}
private static void AddAllVersionToList(IswItem currentVersion, IswItems allVersions)
{
allVersions.Add(currentVersion);
// Iterate over all next versions recursively.
foreach (IswItem nextVersion in currentVersion.NextVersions)
{
AddAllVersionToList(nextVersion, allVersions);
}
}