Get Id of Release State

Get Id of Release State

blokmech
Enthusiast Enthusiast
932 Views
4 Replies
Message 1 of 5

Get Id of Release State

blokmech
Enthusiast
Enthusiast

Hi all,

 

I'm looking for the "Released State" id for a particular lifecycle definition, but I'm lost.

Who can point me to the right direction?

The code I use is:

 

Dim LfCycDefs = serviceManager.DocumentServiceExtensions.GetAllLifeCycleDefinitions
Dim ReleaseProcessID = LfCycDefs.FirstOrDefault(Function(states) states.SysName = "My Release Process")
Dim ReleaseId As Long

  For Each StateID In ReleaseProcessID.StateArray
    If StateID.DispName = "Released" Then
   ReleaseId = StateID.Id
End If
Next

0 Likes
933 Views
4 Replies
Replies (4)
Message 2 of 5

Redmond.D
Autodesk
Autodesk

It looks like you are confusing system name and display name.

 

To find your lifecycle definition you need to run the following comparison:

      states.DispName = "My Release Process"

 



Doug Redmond
Software Engineer
Autodesk, Inc.

0 Likes
Message 3 of 5

blokmech
Enthusiast
Enthusiast

Doug,

 

You are correct, but I think I'm very close to the solution what i want, but still it's not working. It fails on the line starting with " docsvcExt.UpdateFileLifeCycleStates"

I also changed the method of getting the Id(I know it is not the most fine solution...):

 

Dim LfCycDefs = serviceManager.DocumentServiceExtensions.GetAllLifeCycleDefinitions
Dim LifeCycleId As Long
  For Each LfCycle In LfCycDefs
    If LfCycle.DispName = "My Release Process" Then
    LifeCycleId = LfCycle.Id
    End If
  Next

'Get LifeCylceStateID of "Released"
Dim FileStates = ServiceManager.DocumentServiceExtensions.GetLatestRevisionLifeCycleStatesByDefinitionId(LifeCycleId)
Dim ReleaseId() As Long
  For Each StateID In FileStates
    If StateID.DispName = "Released" Then
    ReleaseId = New Long() {StateID.Id}
    End If
  Next

 

Dim docsvcExt As New Autodesk.Connectivity.WebServices.DocumentServiceExtensions

Dim PDFs As Autodesk.Connectivity.WebServices.File() = serviceManager.DocumentService.GetLatestFilesByFolderId(FolderPDFId1, False)
  For Each pdf As Autodesk.Connectivity.WebServices.File In PDFs
    If pdf.FileLfCyc.LfCycStateName = "Work in Progress" Then
    Dim pdfmasterid() As Long = New Long() {pdf.MasterId}
   docsvcExt.UpdateFileLifeCycleStates(New Long() {pdfmasterid(0)}, New Long() {ReleaseId(0)}, "Released for Purchase Department")
    End If
  Next

0 Likes
Message 4 of 5

blokmech
Enthusiast
Enthusiast

Anyone?

0 Likes
Message 5 of 5

Redmond.D
Autodesk
Autodesk

Are there any more details you can give on the failure, such as the error code?

Here is some code for extracting the error and restriction codes.

 



Doug Redmond
Software Engineer
Autodesk, Inc.

0 Likes