Error -5002 when adding a UDF, with B1 9.1

Hello,
in the past I wrote some addons for SAP B1 9.0 and worked well.
Now I just upgraded our SAP B1 32-bit client from 9.0 to 9.1.
If I try to run any of my addons and I get error code -5002, with description "Nessun record dati" ("No data records" in English).
It occures in this piece of code that creates UDFs, when doing Add() the result is -5002 instead of 0:
UserFieldsMD md = (UserFieldsMD)Global.oCompany.GetBusinessObject(BoObjectTypes.oUserFields);
string realFieldName = "U_NS_MYFIELD";
// Setting the Field's properties
md.TableName = "RDR1";
md.Name = "NS_MYFIELD";
md.Description = "My field";
md.Type = BoFieldTypes.db_Alpha;
md.SubType = BoFldSubTypes.st_None;
md.EditSize = 254;
md.Mandatory = BoYesNoEnum.tNO;
// Adding the Field to the Table
int result = md.Add();
Global.ReleaseComObject(md);
This occures both keeping the old 9.0 version of SAPbobsCOM.dll and changing it to the new 9.1 version...
Maybe the mechanism for creating UDFs has been changed? The reference (REFDI.chm) doesn't tell it.
Kind regards

This function is how I create UDF. I'm using it since SAP 8.8
Function CreateUDF(ByVal TableName As String, ByVal FieldName As String, ByVal FieldDescription As String, Optional ByVal UDFLength As Integer = 10, Optional ByVal FieldType As SAPbobsCOM.BoFieldTypes = SAPbobsCOM.BoFieldTypes.db_Alpha, Optional ByVal DefaultValue As Object = "", Optional ByVal ShowMessage As Boolean = False, Optional ByVal dtValidValues As Data.DataTable = Nothing, Optional ByVal LinkedTable As String = "", Optional ByVal FieldSubType As SAPbobsCOM.BoFldSubTypes = Nothing, Optional ByVal isMandatory As SAPbobsCOM.BoYesNoEnum = SAPbobsCOM.BoYesNoEnum.tNO, Optional ByVal isUpdateExisting As Boolean = False) As Boolean
        Try
            Dim FieldID As Integer = GetUDFId(TableName, FieldName)
            oRecset = oDICompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)
            If Not IsNothing(oRecset) Then
                System.Runtime.InteropServices.Marshal.ReleaseComObject(oRecset)
                oRecset = Nothing
                GC.Collect()
            End If
            Dim oUserFields As SAPbobsCOM.UserFieldsMD
            oUserFields = oDICompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserFields)
            Dim isExists As Boolean = False
            'LSC 10/20/2013
            If Not FieldID = -1 Then 'oUserFields.GetByKey(TableName, FieldID) Then
                '  oUserFields.Remove()
                ' If Not isUpdateExisting Then Return True
                Return True
                'oUserFields.Remove()
            End If
            With oUserFields
                If Not isExists Then
                    .TableName = TableName
                    .Name = FieldName
                    .Description = FieldDescription
                    .Type = FieldType
                End If
                .EditSize = UDFLength
                .Mandatory = isMandatory
                Select Case oUserFields.Type
                    Case 4
                        .SubType = FieldSubType
                End Select
                If FieldType = SAPbobsCOM.BoFieldTypes.db_Alpha Or FieldType = SAPbobsCOM.BoFieldTypes.db_Float Or FieldType = SAPbobsCOM.BoFieldTypes.db_Numeric Or FieldType = SAPbobsCOM.BoFieldTypes.db_Date Then
                    If Not DefaultValue = "" Then .DefaultValue = DefaultValue
                End If
                If Not LinkedTable = "" Then .LinkedTable = LinkedTable
                If Not IsNothing(dtValidValues) Then
                    For Loops As Integer = 0 To dtValidValues.Rows.Count - 1
                        .ValidValues.Value = dtValidValues.Rows(Loops).Item("Value")
                        .ValidValues.Description = dtValidValues.Rows(Loops).Item("Description")
                        If Loops <= dtValidValues.Rows.Count - 1 Then .ValidValues.Add()
                    Next
                End If
                If isExists Then
                    If Not .Update = 0 Then
                        If ShowMessage Then SetMessage(oDICompany.GetLastErrorDescription)
                        Return False
                    End If
                Else
                    If Not .Add = 0 Then
                        If ShowMessage Then SetMessage(oDICompany.GetLastErrorDescription)
                        Return False
                    End If
                End If
            End With
            System.Runtime.InteropServices.Marshal.ReleaseComObject(oUserFields)
            oUserFields = Nothing
            GC.Collect()
            Return True
        Catch ex As Exception
            SetMessage(ex)
            Return False
        End Try
    End Function

Similar Messages

  • SDK Error -5002 when adding a sales order

    I'm getting an error -5002 when adding a sales order.
    Source code:
          IDocuments m_so2 = SBOCOMUtil.newDocuments(icmp, SBOCOMConstants.BoObjectTypes_Document_oOrders);
          line = m_so2.getLines();
          m_so2.setCardCode("2173231916");
          m_so2.setCardName("test Sales order");
          SimpleDateFormat formatter = new SimpleDateFormat("dd.MM.yyyy");
          Date today = Calendar.getInstance().getTime();
          m_so2.setDocDueDate(today);
          line.setItemCode("01005");
          line.setDiscountPercent(new Double(10));
          line.setItemDescription("description Testing");
          line.setQuantity(new Double(3));
          line.setTaxCode("0");
          line.add();
          long rc = m_so2.add();
    Question:
    Where can I find a list of error codes that can be easy to understand? PDF, word, etc.
    Thanks.

    Hi Diego,
    Looking at your code I see that you are doing a
    line.add();
    You don’t need to have this here unless you are adding another line to your document.
    Maybe this will help you.
    Also just because java is a bit different from VB get the last error message using
    SBOErrorMessage errMsg= comp.getLastError();
    System.out.println(errMsg.getErrorMessage());
    -Cormac

  • TS1424 error 5002 when trying to purchase with credit card?

    Need to know what error 5002 means when trying to purchase music off of wish list?

    This alert is often the result of an issue with verifying your billing.
    Quit iTunes.
    Open iTunes.
    Test the issue.
    If it persists, sign in to store.apple.com using your iTunes account
    Click on Change account information
    Modify or remove your credit card information.
    Click Continue.
    Test the issue.

  • Error -5002 when I insert quotation with DI API

    Hello everybody.
    I come back to this project but I have always the same problem. I have upgrade a database from version 6.5 to 2004 patch 14.
    Now I want to insert a new quotation with DI API.
    But I have always the error -5002 in ErrCode variable.
    Here the code:
        On Error GoTo Event_Handler
        Dim codcli, str, sel As String
        str = "Select CardCode From OCRD Where CardName = '" & codice_fiera & "' AND CardType = 'C'"
        oRS.DoQuery str
        codcli = CStr(oRS.Fields.Item(0).Value)
        Dim i As Integer
        Dim flag As Boolean
        Dim RetVal, RetValOrd As Long
        RetVal = 1
        RetValOrd = 1
        flag = True
        Set vQuotation = pCompany.GetBusinessObject(oQuotations)
        Dim NumOrd As Long
        Dim CodArt As String
        For i = 1 To N
                Set oEditText = oMatrice.Columns("col1").Cells.Item(i).Specific
                sel = oEditText.String
                If (sel <> "") Then
                    If (flag) Then
                        vQuotation.Series = 1011
                        vQuotation.CardCode = codcli
                        vQuotation.HandWritten = tNO
                        vQuotation.DocDate = Date
                        vQuotation.DocDueDate = Date
                        Dim tipo_ord As String
                        Set oEditText = oMatrice.Columns("col11").Cells.Item(i).Specific
                        tipo_ord = CStr(oEditText.String)
                        str = "Select Code From [@CAUSALI] Where Name = '" & tipo_ord & "'"
                        oRS.DoQuery str
                        vQuotation.UserFields("U_tpor").Value = CStr(oRS.Fields.Item(0).Value)
                        flag = False
                    End If
                        Set oEditText = oMatrice.Columns("col2").Cells.Item(i).Specific
                        CodArt = CStr(oEditText.String)
                        vQuotation.Lines.ItemCode = oEditText.String
                        Set oEditText = oMatrice.Columns("col3").Cells.Item(i).Specific
                        vQuotation.Lines.ItemDescription = oEditText.String
                        Set oEditText = oMatrice.Columns("col4").Cells.Item(i).Specific
                        vQuotation.Lines.Quantity = oEditText.String
                        Dim Qta As Double
                        Qta = Val(oEditText.String)
                        vQuotation.Lines.UserFields("U_qta_cons").Value = Qta
                        vQuotation.Lines.UserFields("U_tipo").Value = codice_fiera
                        Set oEditText = oMatrice.Columns("col9").Cells.Item(i).Specific
                        vQuotation.Lines.UserFields("U_Inizio").Value = oEditText.String
                        Set oEditText = oMatrice.Columns("col10").Cells.Item(i).Specific
                        vQuotation.Lines.UserFields("U_Fine").Value = oEditText.String
                        str = "ordine nr. "
                        Set oEditText = oMatrice.Columns("col6").Cells.Item(i).Specific
                        NumOrd = Val(oEditText.String)
                        str = str & oEditText.String
                        Set oEditText = oMatrice.Columns("col5").Cells.Item(i).Specific
                        str = str & " a " & oEditText.String
                        vQuotation.Lines.FreeText = str
                        str = "Select Price, DiscPrcnt, VatGroup, WhsCode From RDR1 Where DocEntry = " & NumOrd & " AND ItemCode = '" & CodArt & "'"
                        oRS.DoQuery str
                        vQuotation.Lines.Price = Val(oRS.Fields.Item(0).Value)
                        vQuotation.Lines.DiscountPercent = Val(oRS.Fields.Item(1).Value)
                        vQuotation.Lines.VatGroup = CStr(oRS.Fields.Item(2).Value)
                        vQuotation.Lines.WarehouseCode = CStr(oRS.Fields.Item(3).Value)
                        vQuotation.Lines.Add
                        str = "Select LineNum, U_qta_cons From RDR1 Where DocEntry = " & NumOrd & " And ItemCode = '" & CodArt & "'"
                        oRS.DoQuery str
                        Dim RigaNum As Long
                        RigaNum = oRS.Fields.Item(0).Value
                        Dim QtaCons As Double
                        QtaCons = Val(oRS.Fields.Item(1).Value) + Qta
                        str = "Update RDR1 Set U_qta_cons = " & QtaCons & "Where DocEntry = " & NumOrd & "And LineNum = " & RigaNum
                        oRS.DoQuery str
                End If
        Next
        If (Not flag) Then
            RetVal = vQuotation.Add
        End If
        Dim ErrCode As Long
        Dim ErrMsg As String
        If RetVal <> 0 Then
            pCompany.GetLastError ErrCode, ErrMsg
            str = "Offerta non generata!" & ErrCode & " " & ErrMsg
        Else
            str = "Offerta generata correttamente!"
        End If
        oMessaggio.Caption = str
    Event_Handler:
        If Err.Number <> 0 Then
            SBOApplication.MessageBox (Err.Description)
        End If
    Thanks for your help.
    Regards,
    Veronica Vezzali

    Hi Veronica,
    Be sure that you have created a posting period for 2005 (current year). I.e. Administration | System Initialisation | General Settings | Posting Periods.
    After that you should be able to connect with your DI.
    Marcel

  • Error -5002 when adding linked user defined field using DI API

    Hello,
    When I try to add a linked user defined field using DI API I get the error number -5002 with description:
    "The field 'Related Table' should consist of 8 alphanumeric characters with no valid or default values"
    I Get the error when I use the Add method.
    What is the solution for this problem? I use SBO 2005 A SP1 Patch 18
    The code I use is (.NET C# 2.0):
    SAPbobsCOM.IUserFieldsMD uf = (SAPbobsCOM.IUserFieldsMD)company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserFields);
    uf.Name = "S_BUCO";
    uf.TableName = "OPOR";
    uf.Type = SAPbobsCOM.BoFieldTypes.db_Memo;
    uf.SubType = SAPbobsCOM.BoFldSubTypes.st_Link;
    uf.LinkedTable = "S_BU";
    uf.Description = "Description";
    uf.Add()
    Regards,
    Jeffrey

    Hi Jeffrey,
    Your code above does not match the settings you are using in the UI. In particular, the type and subtype you are setting in code are not correct.
    To create the UDF via code, set the field types as follows:
    SAPbobsCOM.IUserFieldsMD uf = (SAPbobsCOM.IUserFieldsMD)company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserFields);
    uf.Name = "S_BUCO";
    uf.TableName = "OPOR";
    uf.Type = SAPbobsCOM.BoFieldTypes.db_Alpha;
    uf.EditSize = 8;
    uf.LinkedTable = "S_BU";
    uf.Description = "Description";
    uf.Add()
    There's no need to set the SubType property as you require a regular alphanumeric field.
    Kind Regards,
    Owen

  • Version conflict? Error -5002 when adding a sales order in SDK 2004.

    I get the -5002 error without any description when I reference the "SAP Business One Objects Bridge API version 6.2 SP3" and try to add an invoice in SBO 2004. The code is basically:
    Set vDOC = vCmp.GetBusinessObject(oInvoices)
    vDOC.CardCode = "K99999"
    vDOC.CardName = "Nils"
    vDOC.Lines.ItemCode = "A00001"
    VDOC.Add
    The routine works well if I reference the SBO 2004 DI API or if I run it on a 6.5 system.
    How can I be sure that my routine can work in both versions?
    /Nils.
    Message was edited by: Nils Jakob Heyerdahl

    I run Windows XP Proffessional with SP2.
    1) I had 6.5 SP1 installed. My POS-app works well. I have a procedure that adds an invoice from the POS-app. The VB-project (VB6 SP5) references "SAP Business One Objects Bridge API version 6.2 SP3" (because I want to support all versions of SBO).
    2) I uninstall SBO 6.5 and install SBO 2004 (III).
    3) I start the POS-app and receives an error when I try to add a document. The message is "-5002,". No text after the errorcode.
    4) I then deletes the reference to "SAP Business One Objects Bridge API version 6.2 SP3" and reference the "SAP Business One DI API Version 2004".
    5) I then start the POS-app again and no error occurs.
    The code I debuged with is as simple as this:
        Set vDOC = vCmp.GetBusinessObject(oInvoices)
        Set vOCRD = vCmp.GetBusinessObject(oBusinessPartners)
        vDOC.CardCode = "K99999"
        vDOC.CardName = "Nils"
        vDOC.Add
        vDOC.Lines.ItemCode = "A00001"
        vDOC.Lines.ProjectCode = "    "
        vDOC.Lines.ItemDescription = "Varetekst"
        vDOC.Lines.Quantity = 1
        vDOC.Lines.PriceAfterVAT = 100
        vDOC.Lines.DiscountPercent = 0
        If (0 <> vDOC.Add()) Then
           Call vDOC.SaveXML("SAP_ERR_" & Trim(Str(DocType)) & "_" & Trim(Str(Bong)) + ".xml")
           isCancelled = True
        End if
        Exit Function
    Strange?
    /Nils.

  • Error 9672 when adding USB printer with bonjour

    I cannot get the printer to be added. Everytime it says an error occured #9672.
    I have done all the suggested options to get the printer to add. It is recognized in the add list, and does everything up to adding it to the network, but the error pops up.
    I have updated airport extreme to the newest version.
    macbook pro   Mac OS X (10.4.9)  

    What is the printer make & model that you are connecting to the USB port of the AirPort Extreme Base Station (AEBSn)?
    You may want to double-check this iFelix site to see if it's compatible with the AEBSn.

  • Error 5002 when trying to login with apple ID.

    Just had a new HD installed in my 4year old MacbookPro. Need yo update some of my Apps. Not sure what to do.

    Are you getting this when trying to access the App Store?
    Connecting to App Store Problems

  • Error 5 when adding to PSA

    Hi All,
    I faced an error 'Error 5 when adding to PSA'  (going into short dump ABAP runtime erro : Message Type X Erro). I am trying to load the data from ODS to another ODS with full upadte through PSA . I am facing this error. Can anybody help me in this issue. Please this is very urgent, all the dependant loads are stopped in production.
    Thanks in Advance
    Narendra

    Thanks, This is solved by myself. I deleted all the failed requests in the PSA.

  • HT3275 Since updating OS to Mountain Lion from leopard, I get the following error message when trying to backup with time machine on external drive.  Could not complete backup to media share.  The network backup disk does not support the required AFP feat

    Since updating OS to Mountain Lion from leopard, I get the following error message when trying to backup with time machine on external drive.  "Could not complete backup to media share.  The network backup disk does not support the required AFP features."  What are AFP features and how do I get Time Machine to backup to my current external backup?

    This means that your NAS does not support the required encryption. Update your NAS to the latest firmware or ditch it and buy a Time Capsule (they are the most reliable when using TM).

  • Getting error 789 when trying to connect with a PC remotely via VPN

    When we set up the VPN we are getting a Error 789 when trying to connect with a PC. Any suggestions would be appreciated.

    The utilities, provided on the CD, are not required for the PC to access the Internet through the 802.11n AirPort Extreme Base Station (AEBSn). They are only necessary for administering the base station.
    If your PC is currently configured as a DHCP client, it shouldn't have any issues connecting by Ethernet. The AEBSn will assign the appropriate IP addresses required for connectivity to the Internet ... just like it does for wireless clients.

  • I have a Macbook Pro that I have just renewed and transferred over my old hard drive (also from a Macbook Pro). Now when I turn on the computer and ITunes opens I get error (-50) and then error 5002 when I try to sign in to ITunes Store - Help!

    I have a Macbook Pro that I have just renewed and transferred over my old hard drive (also from a Macbook Pro). Now when I turn on the computer and ITunes opens I get error (-50) and then error 5002 when I try to sign in to ITunes Store - Help!
    My dealer has tried and failed (twice) to correct this and I have tried deleting the two items in the Itunes folder but no luck!

    were you able to get help on this?  I need help on error 5002 as well.  thank you

  • I get error 5002 when trying to redeem gift cards , what do I need to do to fix this.

    I get error 5002 when trying to redeem gift cards, what can I do to fix this?

    http://store.apple.com/us
    I have been trying to fix this myself and just found a way tonight. This started happening after I downloaded a new version. I tried several other approaches and was unsuccessful until I was directed to the support website.  I searched for 5002 error.  I chose specific conditions and alert message.  Then chose "Error 5002" which gave a little detail. 
    Basically I had to go to the above site and change my password and some other account information.  It didn't work when I tried in my actual ITUNES application.  I think because my account was so old and they upgraded some security items like stronger passwords etc., so the old stuff was no longer good enough.  I have now redeemed two gift cards.  I hope it helps.

  • I get error 5002 when trying to buy 3.1 software for iPod touch 1st gen

    I get error 5002 when trying to buy 3.1 software for iPod touch 1st gen. 

    That is a paid update you get here:
    Purchasing iOS 3.1 Software Update for iPod touch (1st generation)

  • I keep getting "Error 5002" When I try to buy an album. What do I do?

    I keep getting "Error 5002" When I try to buy an album. What do I do? I already reinstalled iTunes... not sure what this error means or how to be able to buy this album.

    There's some info on your error message number in the Specific Conditions and Alert Messages: (Mac OS X / Windows) section of the following document:
    iTunes: Advanced iTunes Store troubleshooting

Maybe you are looking for

  • Question about id3 tags

    i had all of the fields of all my songs just how i liked them. i thought itunes had written everything i had edited into the id3 tags of all the songs. apparently, it didn't work. i am using another software called serato. i took the mp3's whose tags

  • Help with exporting to pdf

    If someone could help me with this I would greatly appreciate it!! Using Indesgin CS3: I am trying to export page by page of an indesign document....there are 16 pages and when I get to page 8, it tells me that it is an invalid page name.....? Any id

  • OS Version:_6.1.7601.2.1.0.256.1

    Hi, I am frequently getting below error could any help me to fix this issue Problem signature:   Problem Event Name: BlueScreen   OS Version: 6.1.7601.2.1.0.256.1   Locale ID: 1033 Additional information about the problem:   BCCode: 1a   BCP1: 000417

  • Third party order type

    Hi all, Pls tell me what is order type of third party? I don't see it in VOV8. Thanks,

  • Format of the JNDI name for lookup in DataSource

    Hi a) I have made a datasource in Weblogic 10.3 called SQL and its JNDI name as jdbc/SQLDS. The driver was BEA'S Type 4 Driver for MS SQL Server Now I am trying to lookup the datasource through an application. I have used the following lines of code: