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: 

"Value of type long can not be converted to 1-dimansional array of long"

7 REPLIES 7
SOLVED
Reply
Message 1 of 8
Anonymous
899 Views, 7 Replies

"Value of type long can not be converted to 1-dimansional array of long"

Anonymous
Not applicable

I try to change the status on a file from work in progress to released.

 

but i keep getting the error "Value of type long can not be converted to 1-dimansional array of long"

 

please help with this, i cant figure out how to change the file status 😞

 

 Dim files As File() = docSvc.GetLatestFilesByFolderId(parentFolder.Id, False)

        If (Not files Is Nothing AndAlso files.Length > 0) Then

            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)

                    MsgBox(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 MyLifecycleDefinition As LfCycDef

                    Dim docsvcExt As Autodesk.Connectivity.WebServices.DocumentServiceExtensions

                    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 ThisFileLifeCyclestateID = 24 Then

                        ThisFileLifeCyclestateID = 26

                        Dim Thisfile As File

                        Thisfile = docsvcExt.UpdateFileLifeCycleStates(ThisFileMasterID, ThisFileLifeCyclestateID, ("TEST RELEASE"))

                    End If

                    Exit For

                End If

            Next file

        End If

 

0 Likes

"Value of type long can not be converted to 1-dimansional array of long"

I try to change the status on a file from work in progress to released.

 

but i keep getting the error "Value of type long can not be converted to 1-dimansional array of long"

 

please help with this, i cant figure out how to change the file status 😞

 

 Dim files As File() = docSvc.GetLatestFilesByFolderId(parentFolder.Id, False)

        If (Not files Is Nothing AndAlso files.Length > 0) Then

            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)

                    MsgBox(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 MyLifecycleDefinition As LfCycDef

                    Dim docsvcExt As Autodesk.Connectivity.WebServices.DocumentServiceExtensions

                    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 ThisFileLifeCyclestateID = 24 Then

                        ThisFileLifeCyclestateID = 26

                        Dim Thisfile As File

                        Thisfile = docsvcExt.UpdateFileLifeCycleStates(ThisFileMasterID, ThisFileLifeCyclestateID, ("TEST RELEASE"))

                    End If

                    Exit For

                End If

            Next file

        End If

 

7 REPLIES 7
Message 2 of 8
Redmond.D
in reply to: Anonymous

Redmond.D
Autodesk
Autodesk

The second parameter in UpdateFileLifeCycleStates needs an array of Long values.  You are passing in a Long instead of a Long().

 

Also you don't want to hard-code the lifecycle ID values.  It's fine for testing, but those numbers may change.  A better approach is to look lifecycle state based on its system name, which will not change.  You do this by calling GetLifeCycleDefinitionsByIds then scanning through the results for the LfCycDef that matches the system name.



Doug Redmond
Software Engineer
Autodesk, Inc.

0 Likes

The second parameter in UpdateFileLifeCycleStates needs an array of Long values.  You are passing in a Long instead of a Long().

 

Also you don't want to hard-code the lifecycle ID values.  It's fine for testing, but those numbers may change.  A better approach is to look lifecycle state based on its system name, which will not change.  You do this by calling GetLifeCycleDefinitionsByIds then scanning through the results for the LfCycDef that matches the system name.



Doug Redmond
Software Engineer
Autodesk, Inc.

Message 3 of 8
Anonymous
in reply to: Redmond.D

Anonymous
Not applicable

I know that this is the problem but please show me how to pass / decleare this long() array?

I can figure out how to declare this. I really need to figure this out bud i am stuckt here 😞

 

Can you please show how to do this the right way?

 

Regards.

 

Kent boettger

 

0 Likes

I know that this is the problem but please show me how to pass / decleare this long() array?

I can figure out how to declare this. I really need to figure this out bud i am stuckt here 😞

 

Can you please show how to do this the right way?

 

Regards.

 

Kent boettger

 

Message 4 of 8
jan.liska
in reply to: Anonymous

jan.liska
Autodesk
Autodesk

This is correct way how to call UpdateFileLifeCycleStates in VB.NET - you need to pass arrays fro both masterdIds and stateIds arguments:

 

Thisfile = docsvcExt.UpdateFileLifeCycleStates(New Long() { ThisFileMasterID }, New Long() { ThisFileLifeCyclestateID }, "TEST RELEASE")


Jan Liska
Developer Advocate, Autodesk Tandem

0 Likes

This is correct way how to call UpdateFileLifeCycleStates in VB.NET - you need to pass arrays fro both masterdIds and stateIds arguments:

 

Thisfile = docsvcExt.UpdateFileLifeCycleStates(New Long() { ThisFileMasterID }, New Long() { ThisFileLifeCyclestateID }, "TEST RELEASE")


Jan Liska
Developer Advocate, Autodesk Tandem

Message 5 of 8
Anonymous
in reply to: jan.liska

Anonymous
Not applicable

Thank you Jan, I changed my code according to your recommendations tried this new code but now i get a new error. reference to object net set? What is the problem here.

 

  Dim files As File() = DocSrv.GetLatestFilesByFolderId(parentFolder.Id, False)

        If (Not files Is Nothing AndAlso files.Length > 0) Then

            For Each file As File In files

                Dim MyfileName(0) As String

                MyfileName(0) = Me.TextBox1.Text '"VAULT002.idw"

                If file.Name = MyfileName(0) Then

                    With file

                        MsgBox("File found")

                        Try

                            '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

                            'Get FileID
                            Dim ThisFileID As Long = file.Id

                            'Get file master ID
                            Dim ThisFileMasterID() As Long = New Long() {DocSrv.GetFileById(file.Id).MasterId}

                            'Create array of LyfecycleStates
                            Dim ThisFileLifeCycleState() As Long = New Long() {24, 25, 26, 27}

                            Dim MyFileToUpdate As File = DocSrv.GetFileById(file.Id)

                            'Update file LifeCycle state
                            With MyFileToUpdate

                                'MsgBox((ThisFileMasterID(0) & ":" & (ThisFileLifeCycleState(2) & ":" & "TEST RELEASE")))

                                DocSrvExt.UpdateFileLifeCycleStates(New Long() {ThisFileMasterID(0)}, New Long() {ThisFileLifeCycleState(2)}, "TEST RELEASE")

                                MsgBox("LifeCycle state Changed")

                            End With

                        Catch ex As Exception

                            'ERROR HERE "Object reference not set to an instance of an object"
                            MsgBox(ex.Message)

                        End Try

                    End With

                    Exit For

                End If

            Next file

        End If

 

0 Likes

Thank you Jan, I changed my code according to your recommendations tried this new code but now i get a new error. reference to object net set? What is the problem here.

 

  Dim files As File() = DocSrv.GetLatestFilesByFolderId(parentFolder.Id, False)

        If (Not files Is Nothing AndAlso files.Length > 0) Then

            For Each file As File In files

                Dim MyfileName(0) As String

                MyfileName(0) = Me.TextBox1.Text '"VAULT002.idw"

                If file.Name = MyfileName(0) Then

                    With file

                        MsgBox("File found")

                        Try

                            '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

                            'Get FileID
                            Dim ThisFileID As Long = file.Id

                            'Get file master ID
                            Dim ThisFileMasterID() As Long = New Long() {DocSrv.GetFileById(file.Id).MasterId}

                            'Create array of LyfecycleStates
                            Dim ThisFileLifeCycleState() As Long = New Long() {24, 25, 26, 27}

                            Dim MyFileToUpdate As File = DocSrv.GetFileById(file.Id)

                            'Update file LifeCycle state
                            With MyFileToUpdate

                                'MsgBox((ThisFileMasterID(0) & ":" & (ThisFileLifeCycleState(2) & ":" & "TEST RELEASE")))

                                DocSrvExt.UpdateFileLifeCycleStates(New Long() {ThisFileMasterID(0)}, New Long() {ThisFileLifeCycleState(2)}, "TEST RELEASE")

                                MsgBox("LifeCycle state Changed")

                            End With

                        Catch ex As Exception

                            'ERROR HERE "Object reference not set to an instance of an object"
                            MsgBox(ex.Message)

                        End Try

                    End With

                    Exit For

                End If

            Next file

        End If

 

Message 6 of 8
jan.liska
in reply to: Anonymous

jan.liska
Autodesk
Autodesk
Accepted solution

The error means that you're trying to use object which is not initialized yet. I suggest to check your code under debugger to find out more details.


Jan Liska
Developer Advocate, Autodesk Tandem

0 Likes

The error means that you're trying to use object which is not initialized yet. I suggest to check your code under debugger to find out more details.


Jan Liska
Developer Advocate, Autodesk Tandem

Message 7 of 8
Anonymous
in reply to: jan.liska

Anonymous
Not applicable

Thanks a lot for your help on this, now i got it all working 🙂 happy me 🙂 i tried to debug with no luck, but then i and addet the DocumentServiceExtensions to my login code and now everything works. Just saved month of work, before we go life with our vault. Now i can release all AutoCAD drawings in the vault with one click! When you ever come to Denmark i will buy you a Beer 🙂 below is the missing part of my code in case others have the same problem.

Dim DocSrvExt As DocumentServiceExtensions = New DocumentServiceExtensions()

        DocSrvExt.SecurityHeaderValue = New Autodesk.Connectivity.WebServices.DocumentExSvc.SecurityHeader()
        DocSrvExt.SecurityHeaderValue.UserId = winAuthSvc.SecurityHeaderValue.UserId
        DocSrvExt.SecurityHeaderValue.Ticket = winAuthSvc.SecurityHeaderValue.Ticket
        DocSrvExt.Url = "http://" + serverName + "/AutodeskDM/Services/DocumentServiceExtensions.asmx"

 

0 Likes

Thanks a lot for your help on this, now i got it all working 🙂 happy me 🙂 i tried to debug with no luck, but then i and addet the DocumentServiceExtensions to my login code and now everything works. Just saved month of work, before we go life with our vault. Now i can release all AutoCAD drawings in the vault with one click! When you ever come to Denmark i will buy you a Beer 🙂 below is the missing part of my code in case others have the same problem.

Dim DocSrvExt As DocumentServiceExtensions = New DocumentServiceExtensions()

        DocSrvExt.SecurityHeaderValue = New Autodesk.Connectivity.WebServices.DocumentExSvc.SecurityHeader()
        DocSrvExt.SecurityHeaderValue.UserId = winAuthSvc.SecurityHeaderValue.UserId
        DocSrvExt.SecurityHeaderValue.Ticket = winAuthSvc.SecurityHeaderValue.Ticket
        DocSrvExt.Url = "http://" + serverName + "/AutodeskDM/Services/DocumentServiceExtensions.asmx"

 

Message 8 of 8
jan.liska
in reply to: Anonymous

jan.liska
Autodesk
Autodesk

Glad to hear that you were able to solve the problem. If you're using 2012 release I suggest to look at WebServiceManager class which is available in Autodesk.Connectivity.WebServicesTools. The class simplifies access to individual web service classes.


Jan Liska
Developer Advocate, Autodesk Tandem

0 Likes

Glad to hear that you were able to solve the problem. If you're using 2012 release I suggest to look at WebServiceManager class which is available in Autodesk.Connectivity.WebServicesTools. The class simplifies access to individual web service classes.


Jan Liska
Developer Advocate, Autodesk Tandem

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

Post to forums  

Autodesk Design & Make Report