Community
Vault Customization
Share your knowledge, ask questions, and explore popular Vault API, Data Standard, and VBA topics related to programming, creating add-ins, or working with the Vault API.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Get folder ID from full Vault path

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
pball
165 Views, 2 Replies

Get folder ID from full Vault path

I'd like to get the folder ID from a full Vault path. I'm currently using FindFolderBySearchConditions and that did not work when I feed it a full path. Below is an example of the folder path I'd like to get the ID for and the current code I'm using.

 

$/Designs/Reference Parts

 

    Function Get_Folder_ID(FolderPath As String) As Long()
        Dim mVltCon As VDF.Vault.Currency.Connections.Connection = VB.ConnectionManager.Instance.Connection
        If mVltCon Is Nothing Then Return Nothing

        Dim FolderPropsDef As ACW.PropDef() = mVltCon.WebServiceManager.PropertyService.GetPropertyDefinitionsByEntityClassId("FILE")

        Dim ACWNamePropDef As ACW.PropDef = FolderPropsDef.[Single](Function(n) n.SysName = "Name")

        'Set search options, opereator 3 is exact
        Dim NameSearch As New ACW.SrchCond() With {
            .PropDefId = ACWNamePropDef.Id,
            .PropTyp = ACW.PropertySearchType.SingleProperty,
            .SrchOper = 3,
            .SrchRule = ACW.SearchRuleType.Must,
            .SrchTxt = FolderPath
        }

        Dim bookmark As String = String.Empty
        Dim status As ACW.SrchStatus = Nothing
        Dim results As ACW.Folder() = mVltCon.WebServiceManager.DocumentService.FindFoldersBySearchConditions(New ACW.SrchCond() {NameSearch}, Nothing, Nothing, False, bookmark, status)

        Dim id As Long() = {results(0).Id}

        Return id
    End Function

 

2 REPLIES 2
Message 2 of 3
ericbouwkamp
in reply to: pball

DocumentService contains a FindFoldersByPaths method

Message 3 of 3
pball
in reply to: ericbouwkamp

Thanks for pointing that out. I was able to make that function much smaller and robust with that command.

 

    Function Get_Folder_ID(FolderPath As String) As Long()
        Dim mVltCon As VDF.Vault.Currency.Connections.Connection = VB.ConnectionManager.Instance.Connection
        If mVltCon Is Nothing Then Return Nothing

        Dim results As ACW.Folder() = mVltCon.WebServiceManager.DocumentService.FindFoldersByPaths(New String() {FolderPath})

        Dim id As Long() = {results(0).Id}

        Return id
    End Function

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report