• Industries
  • Products
  • Buy
  • Services & Support
  • Communities
  • Discussion Groups

    Autodesk Vault Customization

    Reply
    Active Contributor kbo
    Active Contributor
    kbo
    Posts: 32
    Registered: 08-18-2010
    Accepted Solution

    change state on every file in vault

    142 Views, 3 Replies
    01-23-2012 12:10 PM

    We have checked in a lot of files into vault professional but not every file has got the released state, is it possible to check for files in the vault with the extension "dwg" that has the state "work in progress" and set them all to released? does anybody know how do do this.

     

    maybe somebody has a small code example they are willing to share.

     

    regards

     

    Kent boettger.

    Employee
    Posts: 19
    Registered: 10-18-2006

    Re: change state on every file in vault

    01-24-2012 12:15 AM in reply to: kbo

    If you mean lifecycle state of the document then DocumentServiceExtensions.UpdateFileLifeCycleStates is the method. Note - by default it isn't possible to release parent without releasing children so you need to either release all associated docoments within one call (you can pass multiple file master ids to the method) or release children first and then release parents. This behaviour can be changed on Vault Settings - Behaviors - Lifecycles. There is checkbox called Check that dependent children are 'Released'.

     

    If the file is controlled by Item they you can release an item using ItemService.UpdateLifeCycleStates. 



    Jan Liska
    Technical Consultant
    Autodesk, Inc.
    Active Contributor kbo
    Active Contributor
    kbo
    Posts: 32
    Registered: 08-18-2010

    Re: change state on every file in vault

    02-02-2012 05:09 PM in reply to: jan.liska

    I cant figure this out? please help what is the problem in this my code.

     

    i want to change my file from work in progress to released.

     

    but i keep getting an error on the second last line of code :-(

     

    For Each file As File In files
    
                    Dim MyfileName(0) As String
    
                    MyfileName(0) = "VAULT002.idw"
    
                    If file.Name = MyfileName(0) Then
    
                        'MsgBox(file.FileLfCyc.LfCycStateId.ToString)
    
                        m_listBox.Items.Add(parentFolder.FullName & "/" & file.Name & " - " & "FilID: " & file.Id & " - " & "FilMasterID: " & file.MasterId)
    
                        Dim ThisFileID As Long = file.Id
    
                        Dim ThisFileMasterID(0) As Long
    
                        ThisFileMasterID(0) = file.MasterId
    
                        'Lifecycle Definitions
                        'Name : Monsun Basic Release Process = 6
    
                        'Lifecycle States
                        'Work in Progress = LifecyclestateID 24
                        'For Review = LifecyclestateID 25
                        'Released = LifecyclestateID 26
                        'Obsolete = LifecyclestateID 27
    
                        Dim ThisFileLifecycleStateName As String = docSvc.GetFileById(ThisFileID).FileLfCyc.LfCycStateName
                        Dim ThisFileLifeCyclestateID As Long = docSvc.GetFileById(ThisFileID).FileLfCyc.LfCycStateId
                        Dim ThisFileLifeCycledefinitionID As Long = docSvc.GetFileById(ThisFileID).FileLfCyc.LfCycDefId
    
                        MsgBox("LifecyclestateName: " & ThisFileLifecycleStateName & " - LifecyclestateID: " & ThisFileLifeCyclestateID & " - Lifecycledefinition: " & ThisFileLifeCycledefinitionID)
    
                        If file.FileLfCyc.LfCycStateId.ToString = "24" Then
    
                            Dim MyLyfeCycleState As Long() = New Long(System.Convert.ToInt64("Released")) {}
                            'MyLyfeCycleState(24) = System.Convert.ToInt64("Work in Progress")
                            'MyLyfeCycleState(25) = System.Convert.ToInt64("For Review")
                            'MyLyfeCycleState = System.Convert.ToInt64("Released")
                            'MyLyfeCycleState(27) = System.Convert.ToInt64("Obsolete")
    
                            'Dim Released As Long = System.Convert.ToInt64("26")
    
                            Dim docsvcExt As Autodesk.Connectivity.WebServices.DocumentServiceExtensions
    
                            Dim Thisfile As File
    
                            Thisfile = docsvcExt.UpdateFileLifeCycleStates(ThisFileMasterID, MyLyfeCycleState, "TEST RELEASE")
    
                        End If

     

    Employee
    Posts: 19
    Registered: 10-18-2006

    Re: change state on every file in vault

    02-03-2012 10:56 AM in reply to: kbo

    What's the error code, please?

     

    I see that you're using hardcoded ids for states - it's better to get state id from LfCycDef.StateArray.

     

    There could be following issues:

    - the code is setting same lifecycle state which is already set

    - the code is setting state which doesn't belong to associated lifecycle definition

    - the user doesn't have permission to change state



    Jan Liska
    Technical Consultant
    Autodesk, Inc.