cancel
Showing results for 
Search instead for 
Did you mean: 

UDO creation error- invalid user

Former Member
0 Kudos
52

i am trying to craeate UDO using coding .

but error is coming like that

lRetCode= -1120

msg " invalid user & password"

Any solution

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Avjit,

it is strange that you get 'invalid user' exception. usually the error -1120 is for 'Ref count for this object is higher then 0. ' which implies that some other metadata object such as recordset, Userfield or Usertable object which must have been created before creating this UDO is still alive. you will find several thread for this error. you can manually check if you have added

this code


System.Runtime.InteropServices.Marshal.ReleaseComObject(instance of your metadata object)

in your field and table creation functions, which should get executed before you create UDO.

HTH,

Binita

Former Member
0 Kudos

Thank binita.

Its help me to find out right solutions.

i gave u point also for help me.

Thank,

Avijit

Answers (2)

Answers (2)

Former Member
0 Kudos

it's working

Former Member
0 Kudos

Hi AVIJIT,

Check to see if the user you're running you add-on with, has a Professional License assign, and has enough permissions to create user objects.

Best Regards,

Vítor Vieira

Former Member
0 Kudos

Hi Binta,

I have tried your code.

also try below code -

If lRetCode = 0 Then

OCompany.GetLastError(lRetCode, sErrMsg)

MsgBox(sErrMsg)

Else

OCompany.GetLastError(lRetCode, sErrMsg)

MsgBox(sErrMsg)

System.Runtime.InteropServices.Marshal.ReleaseComObject(oUserFieldsMD)

oUserFieldsMD = Nothing

End If

i have used this code at the time of creation user defined field.

And after that i am trying to run UDO code. but still same problem.

Former Member
0 Kudos

AVIJIT,

Check if user has a Professional License assigned.

Have you managed to register other objects with problem before?

Have you tried to register the object in the B1 GUI?

Also I include code samples in how to register Master Data and Document Objects.

Master Data with child table


Private Function RegisterTRAD(ByRef oCompany As SAPbobsCOM.Company, ByRef oApplication As SAPbouiCOM.Application) As Boolean
        RegisterTRAD = False

        Dim oUserObjectMD As UserObjectsMD = oCompany.GetBusinessObject(BoObjectTypes.oUserObjectsMD)
        Dim lRetCode As Long

        Try
            If Not oUserObjectMD.GetByKey("ADAT_TRAD") Then
                oUserObjectMD.Code = "ADAT_TRAD"
                oUserObjectMD.Name = "Traduções"
                oUserObjectMD.ObjectType = BoUDOObjType.boud_MasterData
                oUserObjectMD.TableName = "ADAT_TRAD"
                oUserObjectMD.CanCancel = BoYesNoEnum.tYES
                oUserObjectMD.CanClose = BoYesNoEnum.tYES
                oUserObjectMD.CanCreateDefaultForm = BoYesNoEnum.tNO
                oUserObjectMD.CanDelete = BoYesNoEnum.tYES
                oUserObjectMD.CanFind = BoYesNoEnum.tYES
                oUserObjectMD.CanLog = BoYesNoEnum.tYES
                oUserObjectMD.CanYearTransfer = BoYesNoEnum.tYES
                oUserObjectMD.LogTableName = "AADAT_TRAD"
                oUserObjectMD.ExtensionName = ""

                oUserObjectMD.FindColumns.ColumnAlias = "Code"
                oUserObjectMD.FindColumns.ColumnDescription = "Código"
                oUserObjectMD.FindColumns.Add()
                oUserObjectMD.FindColumns.SetCurrentLine(1)
                oUserObjectMD.FindColumns.ColumnAlias = "U_TableNam"
                oUserObjectMD.FindColumns.ColumnDescription = "Nome da Tabela"
                oUserObjectMD.FindColumns.Add()
                oUserObjectMD.FindColumns.ColumnAlias = "U_TableDsc"
                oUserObjectMD.FindColumns.ColumnDescription = "Descrição da Tabela"
                oUserObjectMD.FindColumns.Add()
                oUserObjectMD.FindColumns.ColumnAlias = "U_FieldNam"
                oUserObjectMD.FindColumns.ColumnDescription = "Nome do Campo"
                oUserObjectMD.FindColumns.Add()
                oUserObjectMD.FindColumns.ColumnAlias = "U_FieldDsc"
                oUserObjectMD.FindColumns.ColumnDescription = "Descrição do Campo"
                oUserObjectMD.FindColumns.Add()

                lRetCode = oUserObjectMD.Add()

                '// Verificar existência de erros ao adicionar o UDO
                If lRetCode <> 0 Then
                    oApplication.MessageBox("RegisterTRAD(Add): " & lRetCode.ToString)
                Else
                    RegisterTRAD = True
                End If
            End If

        Catch ex As Exception
            oApplication.MessageBox("RegisterTRAD(): " & oCompany.GetLastErrorCode & ", " & ex.Message)
        Finally
            System.Runtime.InteropServices.Marshal.ReleaseComObject(oUserObjectMD)
            oUserObjectMD = Nothing
            lRetCode = Nothing
            GC.Collect()
        End Try

    End Function

Document with child table


 Private Function RegisterNR(ByRef oCompany As SAPbobsCOM.Company, ByRef oApplication As SAPbouiCOM.Application) As Boolean
        RegisterNR = False

        Dim oUserObjectMD As UserObjectsMD = oCompany.GetBusinessObject(BoObjectTypes.oUserObjectsMD)
        Dim lRetCode As Long

        Try
            If Not oUserObjectMD.GetByKey("ADAT_NR") Then
                oUserObjectMD.Code = "ADAT_NR"
                oUserObjectMD.Name = "Nota de Recepção"
                oUserObjectMD.ObjectType = BoUDOObjType.boud_Document
                oUserObjectMD.TableName = "ADAT_ONR"
                oUserObjectMD.CanCancel = BoYesNoEnum.tYES
                oUserObjectMD.CanClose = BoYesNoEnum.tYES
                oUserObjectMD.CanCreateDefaultForm = BoYesNoEnum.tNO
                oUserObjectMD.CanDelete = BoYesNoEnum.tYES
                oUserObjectMD.CanFind = BoYesNoEnum.tYES
                oUserObjectMD.CanLog = BoYesNoEnum.tYES
                oUserObjectMD.LogTableName = "AADAT_NR"
                oUserObjectMD.CanYearTransfer = BoYesNoEnum.tYES
                oUserObjectMD.ManageSeries = BoYesNoEnum.tYES
                oUserObjectMD.ChildTables.TableName = "ADAT_NR1"
                oUserObjectMD.ChildTables.LogTableName = "AADAT_NR1"
                oUserObjectMD.ExtensionName = ""

                oUserObjectMD.FindColumns.ColumnAlias = "DocNum"
                oUserObjectMD.FindColumns.ColumnDescription = "Nº do Documento"
                oUserObjectMD.FindColumns.Add()
                oUserObjectMD.FindColumns.SetCurrentLine(1)
                oUserObjectMD.FindColumns.ColumnAlias = "Series"
                oUserObjectMD.FindColumns.ColumnDescription = "Série"
                oUserObjectMD.FindColumns.Add()
                oUserObjectMD.FindColumns.ColumnAlias = "U_CardCode"
                oUserObjectMD.FindColumns.ColumnDescription = "Código do PN"
                oUserObjectMD.FindColumns.Add()
                oUserObjectMD.FindColumns.ColumnAlias = "U_CardName"
                oUserObjectMD.FindColumns.ColumnDescription = "Nome do PN"
                oUserObjectMD.FindColumns.Add()
                oUserObjectMD.FindColumns.ColumnAlias = "U_RefNum"
                oUserObjectMD.FindColumns.ColumnDescription = "Nº de Ref. do Fornecedor"
                oUserObjectMD.FindColumns.Add()
                oUserObjectMD.FindColumns.ColumnAlias = "U_DataRcp"
                oUserObjectMD.FindColumns.ColumnDescription = "Data de Recepção"
                oUserObjectMD.FindColumns.Add()
                oUserObjectMD.FindColumns.ColumnAlias = "U_HoraRcp"
                oUserObjectMD.FindColumns.ColumnDescription = "Hora de Recepção"
                oUserObjectMD.FindColumns.Add()
                oUserObjectMD.FindColumns.ColumnAlias = "U_ItemName"
                oUserObjectMD.FindColumns.ColumnDescription = "Nome do Artigo"
                oUserObjectMD.FindColumns.Add()
                oUserObjectMD.FindColumns.ColumnAlias = "U_PrcName"
                oUserObjectMD.FindColumns.ColumnDescription = "Nome do Parcelário"
                oUserObjectMD.FindColumns.Add()
                oUserObjectMD.FindColumns.ColumnAlias = "U_FolhaNam"
                oUserObjectMD.FindColumns.ColumnDescription = "Folha"
                oUserObjectMD.FindColumns.Add()

                lRetCode = oUserObjectMD.Add()

                '// Verificar existência de erros ao adicionar o UDO
                If lRetCode <> 0 Then
                    oApplication.MessageBox("RegisterNR(Add): " & lRetCode.ToString)
                Else
                    RegisterNR = True
                End If
            End If

        Catch ex As Exception
            oApplication.MessageBox("RegisterNR(): " & oCompany.GetLastErrorCode & ", " & ex.Message)
        Finally
            System.Runtime.InteropServices.Marshal.ReleaseComObject(oUserObjectMD)
            oUserObjectMD = Nothing
            lRetCode = Nothing
            GC.Collect()
        End Try

    End Function

Regards,

Vítor

Former Member
0 Kudos

Hi Vitor,

Thanks for your reply.

Any how i have solved that problem. i hope it's problem regarding metadat not problem regarding licence. Any i have getting very good knowldge from you & Binita.

Thanks ,

Avijit