Need help with PromoteLabelItems

If you are having a problem using Vault, post a message here.

Moderator: SourceGear

Post Reply
dproth_trc
Posts: 9
Joined: Tue Jan 25, 2005 5:06 pm

Need help with PromoteLabelItems

Post by dproth_trc » Tue Jan 25, 2005 5:12 pm

I have a label that was created at the root level ($/) called "Release". Files on this label are considered safe to release. We use the Vault "Promotion" option under View Labels to promote newer versions of files to the Release label.

Now, I am trying to figure out how to do this label promotion programmatically. Below is the code I'm running, but it's returning error code 1205, which translates to: "The requested operation cannot be performed on this type of object."

Since there isn't any documentatation or samples for PromoteLabelItems, I am having a very difficult time figuring out what to do next. Can someone help. Using Vault 2.0.6.

Code: Select all

  Public Function FindReleaseLabelID(Optional ByVal strVaultFile As String = "$/") As Long
    Dim nLabelID As Long, rootID As Long
    Dim discoveredSubItemPaths As String()
    Dim dtLastModified As Date
    Dim repositoryDelta As VaultClientNetLib.ClientService.VaultRepositoryDelta
    Dim fileDelta As VaultClientNetLib.ClientService.VaultFileDelta

    _ci.GetLabelStructureByName("Release", nLabelID, strVaultFile, "", discoveredSubItemPaths, dtLastModified, _
                                repositoryDelta, fileDelta, rootID)

    Return nLabelID
  End Function

  Public Function AddLatestToRelease(ByVal strVaultFile As String) As Integer
    Dim vcfile As VaultClientFile
    vcfile = _ci.TreeCache.Repository.Root.FindFileRecursive(strVaultFile)
    If vcfile Is Nothing Then
      Return -1
    Else
      Dim dtLastChange As Date
      Dim nIdxFailed As Integer
      Dim strRootPathConflict As String
      Dim vlpi(0) As VaultClientNetLib.ClientService.VaultLabelPromotionItem
      vlpi(0) = New VaultClientNetLib.ClientService.VaultLabelPromotionItem
      With vlpi(0)
        .ChangeType = VaultLib.VaultLabelPromotionChangeType.Modify
        .ID = vcfile.ID
        .ItemName = vcfile.Name
        .ItemPath = vcfile.FullPath
        .Version = vcfile.Version
      End With

      Return _ci.PromoteLabelItems(strVaultFile, FindReleaseLabelID(strVaultFile), "Release", dtLastChange, vlpi, nIdxFailed, strRootPathConflict)
    End If
  End Function

jeremy_sg
Posts: 1821
Joined: Thu Dec 18, 2003 11:39 am
Location: Sourcegear
Contact:

Post by jeremy_sg » Wed Jan 26, 2005 1:23 pm

You were very very close. Add

Code: Select all

.ObjVerID = vcfile.ObjVerID
to your with statement, and it should work.

And change

Code: Select all

_ci.PromoteLabelItems(strVaultFile, FindReleaseLabelID(strVaultFile), "Release", dtLastChange, vlpi, nIdxFailed, strRootPathConflict) 
to

Code: Select all

_ci.PromoteLabelItems("$", FindReleaseLabelID(strVaultFile), "Release", dtLastChange, vlpi, nIdxFailed, strRootPathConflict) 
where "$" is the folder where the label was applied.

Post Reply