Adding ValidValues to UserField

I am creating User tables and fields programatically and the ValidValues are not getting added. There is no error message raised after calling the Add method on the ValidValuesMD object. Here's an example:
SAPbobsCOM.UserFieldsMD uf;
SAPbobsCOM.ValidValuesMD vv;
uf = (SAPbobsCOM.UserFieldsMD) sapConnect.SboCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserFields);
uf.TableName = TABLE_NAME;
uf.Name = "StdMark";
uf.Description = "Standard Mark";
uf.Type = SAPbobsCOM.BoFieldTypes.db_Alpha;
uf.SubType = SAPbobsCOM.BoFldSubTypes.st_None;
uf.EditSize = 20;
uf.Mandatory = SAPbobsCOM.BoYesNoEnum.tNO;
uf.DefaultValue = "1";
result = uf.Add();
// StdMark Valid Values
vv = uf.ValidValues;
vv.Value = "1";
vv.Description = "Pre-Printed";
vv.Add();
This code does not look correct and you cannot set the ValidValues property on a UserField (it is read-only). What is the correct way to add ValidValues?

Try setting up the valid values before you call the add method on the user field itself.
eg.
SAPbobsCOM.UserFieldsMD uf;
SAPbobsCOM.ValidValuesMD vv;
uf = (SAPbobsCOM.UserFieldsMD) sapConnect.SboCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserFields);
uf.TableName = TABLE_NAME;
uf.Name = "StdMark";
uf.Description = "Standard Mark";
uf.Type = SAPbobsCOM.BoFieldTypes.db_Alpha;
uf.SubType = SAPbobsCOM.BoFldSubTypes.st_None;
uf.EditSize = 20;
uf.Mandatory = SAPbobsCOM.BoYesNoEnum.tNO;
uf.DefaultValue = "1";
// StdMark Valid Values
vv = uf.ValidValues;
vv.Value = "1";
vv.Description = "Pre-Printed";
vv.Add();
result = uf.Add();
John.

Similar Messages

  • ODBC -2004  (Datei nicht gefunden)  ?????????

    hi,
    since i update SBO 2005 SP00 to Patch Level 10 i get the following error trying to add user fields in a user defined table:
    Datei nicht gefunden (ODBC -2004)
    Does anybody know whats going wrong ?

    Hi Markus same here.
    We can't use our Products with PL10 because of this.
    I sadly don't have a solution but here is the code:
    (and that code always worked on PL9)
    public void addField(string fieldName, string description, SAPbobsCOM.BoFieldTypes type, int editSize, SAPbobsCOM.BoYesNoEnum mandatory, string defaultValue, string linkedTable,Hashtable validValues)
                   SwissAddonFramework.Messaging.Debug.WLine("Add Field: TableName("+tableName+") FieldName("+fieldName+") Description ("+description+") Type("+type.ToString()+") EditSize("+editSize+") linkedTable("+linkedTable+")");
                   SAPbobsCOM.Recordset rs = (SAPbobsCOM.Recordset)company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);
                   rs.DoQuery("SELECT ALIASID FROM CUFD WHERE TABLEID = '@" + tableName + " ' AND ALIASID = '" + fieldName + "'");
                   string aliasID = (string)((SAPbobsCOM.Field)rs.Fields.Item("ALIASID")).Value;
                System.Runtime.InteropServices.Marshal.ReleaseComObject(rs);
                rs = null;
                System.GC.WaitForPendingFinalizers();
                System.GC.Collect();
                   //Falls das Feld bereits existiert wird dieses nicht versucht hinzuzufügen
                   if(aliasID != "") SwissAddonFramework.Messaging.Debug.WLine("Field not added - Field already exists!");
                   else
                        SAPbobsCOM.UserFieldsMD userField = (SAPbobsCOM.UserFieldsMD)company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserFields);
                        userField.TableName = tableName;
                        userField.Name = fieldName;
                        userField.Description = description;
                        userField.Type = type;
                        userField.EditSize = editSize;
                        userField.Mandatory = mandatory;
                        userField.DefaultValue = defaultValue;
                        if (validValues != null) {
                             foreach(string key in validValues.Keys) {
                                  userField.ValidValues.Value=key;
                                  userField.ValidValues.Description=(string)validValues[key];
                                  userField.ValidValues.Add();
                        if(linkedTable != null) userField.LinkedTable = linkedTable;
                        if(userField.Add() != 0) throw new System.Exception(company.GetLastErrorCode() + ": UserField " + fieldName + " on Table " + tableName + " is not possible to create or already exists: " + company.GetLastErrorDescription());
                        SwissAddonFramework.Messaging.Debug.WLine("Field added: TableName("+tableName+") FieldName("+fieldName+") Description ("+description+") Type("+type.ToString()+") EditSize("+editSize+") linkedTable("+linkedTable+")");
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(userField);
                    userField = null;
                    System.GC.WaitForPendingFinalizers();
                    System.GC.Collect();

  • Re:Failed binding data

    Hi all, i have created an edittext in aform and i bind the data to the datasource.While binding, it is showing the error as "Item - Failed binding data  [66000-57]".How should i solve this problem.
    This is my code.
    Private oStatusTxt as SAPbouiCOM.EditText
    oStatusTxt = Form.Items.Item("TxtSts").Specific
    oStatusTxt.DataBind.SetBound(True, "@PSSIT_CMSAMHDR", "U_Status") // i got the error here
    Regards
    Mohana

    Hi,
    The problem is i have added validvalues for the field.but in screenpainter i used edittext and binded to the datadource.i have changed the edittext to combobox, then the problem get solved.
    thanx.
    Regards
    Mohana

  • On Matrix..

    Hi experts,
    I've created a form through screenpainter. The form has a matrix item. The matrix have 3 combo box columns and 1 edittext column.
    Question
    1. I've added ValidValues to the 1st combo boxes throgh the xml. The valid values have a paired value, description parameters. I would like the 2 other combo boxes having only a single value(non-paired) but i'm having a hard time on how to do it. How can this be done?
    2. I will be traversing a matrix cells contents which later i will be saving it on a UDT. The matrix is not bound to the UDT. I would like for your approach guide for this scenario.
    Thank you in advance.
    Manuel

    Hi Manuel,
    1) Unfortunately, the valid values must always have a value and description (and you can't have more than one blank description). The best you can do is to set the value and the description parameters to the same value.
    2) If your UDT is a non-object UDT (ie not a UDO) then you have 2 options to write data to it. The preferred method is to use the UserTables object in the DI API. This has all the methods and properties to insert and update records in a UDT. The alternative approach is to use the Recordset object to insert records using a SQL statement (this is allowed because a non-object UDT is not a system table). Even if the matrix is bound to the UDT via a DBDataSource, you would still need to use one of the options above because a DBDataSource does not save the data back to the table automatically unless your UDT is registered as a UDO.
    Kind Regards,
    Owen

  • Query Ref Problem:Would like UserField updated on adding item to Quotation

    This query works without variable in it - SELECT T1.[U_NPS_QD] FROM OITM T1  INNER JOIN QUT1 T2 ON T1.ItemCode = T2.ItemCode WHERE T1.[ItemCode] = T2.[ItemCode]
    I would like above query to populate a user defined field on Sales Quotation whenever an item is added to quotation or the item is changed. The field I have on Sales Quotation is U_NPS_D2 (it is not in above query). I used form setting to make U_NPS_D2 visible on Sales Quotation. The value I want updated in U_NPS_D2 is from U_NPS_QD (from Item master data).
    I would actually want U_NPS_D2 updated automatically even without user entering Shift F2.
    Where should the $ sign be placed in above query with the right syntax?
    I tried many things and failed.
    Appreciate help.
    Thank you.

    Hi,
    Try This:
    SELECT T1.U_NPS_QD
    FROM OITM T1 INNER JOIN QUT1 T2
    ON T1.ItemCode = T2.ItemCode
    WHERE T1.itemcode =  $[QUT1.itemcode]
    Auto update the field when Item number changes.
    Regards
    Ashutosh
    You should not write " http://"  this is a " [   ] "  actually. But wile i am posting it it comes like http://qut1....
    Cheers..
    Edited by: Ashutosh T on Jun 14, 2010 7:38 AM

  • Error adding a UserField

    Hi gurus !
    I created a UserTable and i want to add UserField in this table. But each times i called the 'Add' method , i've an error (-1) :
    " -1 [Microsoft][SQL Native Client][SQL Server]Ligne 1 : syntaxe incorrecte vers 'max'."
    (invalid syntax near 'max')
    Please help me !!
    Thanks.

    Second times....
    Sorry.

  • Adding Lines to a Sales Order

    Hello !
    I'm using the following code (pretty much) to add items to existing sales orders :
    Dim oOrder As SAPbobsCOM.Documents
    oOrder = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oOrders)
    oOrder.GetByKey(id)
    oOrder.Lines.Add()
    oOrder.Lines.ItemCode = newItemCode
    oOrder.Lines.Quantity = newQuantity
    oOrder.Lines.UserFields.Fields.Item("U_S_Desc").Value = newItemDesc
    lretcode = oOrder.Update
    This works fine for most nearly all of the orders that are processed, however for some of the orders I get the error : No matching Records Found (ODBC -2028).
    I know the record I'm looking for exists, and if Open up the order and add the data manually it works, but something just seems to be stopping the code from doing it.
    I think it might be something to do with the Order's date, but exactly what I don't know.
    I was wondering if anyone's come across something like this before, of if there's an obvious reason why it wouldn't write ?

    Hi,
    Just some suggestions, if you haven't already considered:
    - Before adding new data you should check if the order really exists, like
    if (oOrder.GetByKey(id)) then
    oOrder.Update
    end if
    - The id you search have to be the DocEntry, not the DocNum.
    - The order can't be closed, otherwise yoy can't update.
    Hope this helps,
    Ian

  • Error while  adding records in user defined table

    Dear all,
                    I am adding a record in user defined table using   .add() method. the code is given below. while adding it raises the following error
    "-1[Microsoft]  [SQL Native Client] [SQL Server] Conversion failed when converting the nvarchar value '-3 @BG_MAILSETTINGS'  to data type int. (CINF).  "
    All the fields are varchar date type.  
                Dim oUDT As SAPbobsCOM.UserTable
                oUDT = oCompany.UserTables.Item("BG_MAILSETTINGS")
                With oForm.DataSources.UserDataSources           
                        oUDT.Code = "1"
                        oUDT.Name = "SMTPSERVER"
                        oUDT.UserFields.Fields.Item("U_SERVER").Value = .Item("EDTSMTPSVR").ValueEx
                        oUDT.UserFields.Fields.Item("U_EMAIL").Value = .Item("EDTFEMAIL").ValueEx
                        oUDT.UserFields.Fields.Item("U_PORT").Value = .Item("EDTSMTPPRT").ValueEx
                        oUDT.UserFields.Fields.Item("U_USERNAME").Value = .Item("EDTSMTPUSR").ValueEx
                        oUDT.UserFields.Fields.Item("U_PASSWORD").Value = .Item("EDTSMTPPWD").ValueEx
                        oUDT.UserFields.Fields.Item("U_AUTHENT").Value = .Item("CMBSMTPAUT").ValueEx
                        K = oUDT.Add
                        If K <> 0 Then
                            oCompany.GetLastError(iErrCode, sErrMsg)
                            MsgBox(CStr(iErrCode) & "-" & sErrMsg, vbCritical, "Error")
                            Exit Sub
                        End If
                 End with
    Could any one please say the solution for this.
    Many thanks,
    Manikandan.
    Edited by: Rui Pereira on Dec 23, 2008 3:49 PM

    Dear Manikandan P,
    Is there any change and check in stored procedure SBO_SP_TransactionNotification?
    Best Regards
    Jane Jing
    SAP Business One Forums team
    Edited by: Rui Pereira on Dec 23, 2008 3:56 PM

  • Usertable error after adding a udf

    I have a UI add-on that assigns values ​​to a UDT by usertable object of the DI API, the problem is generated after adding a UDF from SAP menu and try to assign a value from the DI. The error is Invalida Field Name
    My question is, is necessary to wait a while until SAP records the new field to be accessible by usertable?
    Any suggestions?
    oUserTable.UserFields.Fields.Item("U_" + colName).Value = respuesta;

    Hi Ricardo,
    As far as I know, you can use this field as soon as it is added to the usertable. But please make sure that this has been added successfully in your table and also make sure that ("U_" + colName ) is the same as it appears in SQL Server. Make sure that you are providing the right field name.
    Hope it helps.
    Thanks & Regards
    Ankit Chauhan

  • Setting UserField values in document rows

    Hi all
    This is the discription of my problem:
    I have SP1 PL4, moreover I created 2 user Fields in the row’s of documents they are named: U_AnzVE, U_AnzPal
    By code I try to do the following:
    I add a new entry for example a Purchase Order (or any other SAPbobs.Documents). In the row I set the values of the UserFields.
    And at this point my problem ocurs:
    à Each time I set a Field it automaticly adds a new line and the Field value is not set even!
    Here is my Code:
    namespace COR_TestFieldUpdate
        class TesterStart
            public static void Tester()
                try{
                    SAPbobsCOM.Documents purch = (SAPbobsCOM.Documents)SwissAddonFramework.B1Connector.GetB1Connector().Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oPurchaseOrders);
                    purch.CardCode = "100160";
                    purch.DocDueDate = DateTime.Now;
                    purch.Comments = "Comment";
                    for (int i = 0; i < 10; i++)
                        purch.Lines.ItemCode = "IT0940211001.5";
                        purch.Lines.Quantity = i;
                        purch.Lines.ShipDate = DateTime.Now;
                        System.Diagnostics.Debug.WriteLine("cout of lines is:" + purch.Lines.Count);
      //here occures the problem a line is added to the pruch.lines without the Lines.Add command!:
      //And as I said the Value is not set eather...
                        purch.Lines.UserFields.Fields.Item("U_AnzVE").Value = "100";
                        System.Diagnostics.Debug.WriteLine("cout of lines after setting U_AnzVE is:"+purch.Lines.Count);
                     //And here again:
                        purch.Lines.UserFields.Fields.Item("U_AnzPal").Value = "100";
                        System.Diagnostics.Debug.WriteLine("cout of lines after setting U_AnzPal is:" + purch.Lines.Count);
                        if (i != 10 - 1)
                            purch.Lines.Add();
                    ErrorHandler(purch.Add());
                catch(Exception e)
                { System.Diagnostics.Debug.WriteLine("Exeption :"+e.Message); }
            private static void ErrorHandler(int lRetCode)
                string sErrMsg = "";
                int lErrCode = 0;
                if (lRetCode != 0)
                    SwissAddonFramework.B1Connector.GetB1Connector().Company.GetLastError(out lErrCode, out sErrMsg);
                    System.Diagnostics.Debug.WriteLine(lErrCode + " " + sErrMsg);
                    throw new Exception(lErrCode + " " + sErrMsg);
    And this is the output that it is generated:
    cout of lines is:1
    cout of lines after setting U_AnzVE is:2
    cout of lines after setting U_AnzPal is:3
    cout of lines is:4
    cout of lines after setting U_AnzVE is:5
    cout of lines after setting U_AnzPal is:6
    cout of lines is:7
    cout of lines after setting U_AnzVE is:8
    cout of lines after setting U_AnzPal is:9
    cout of lines is:10
    cout of lines after setting U_AnzVE is:11
    cout of lines after setting U_AnzPal is:12
    cout of lines is:13
    cout of lines after setting U_AnzVE is:14
    cout of lines after setting U_AnzPal is:15
    cout of lines is:16
    cout of lines after setting U_AnzVE is:17
    cout of lines after setting U_AnzPal is:18
    cout of lines is:19
    cout of lines after setting U_AnzVE is:20
    cout of lines after setting U_AnzPal is:21
    cout of lines is:22
    cout of lines after setting U_AnzVE is:23
    cout of lines after setting U_AnzPal is:24
    cout of lines is:25
    cout of lines after setting U_AnzVE is:26
    cout of lines after setting U_AnzPal is:27
    cout of lines is:28
    cout of lines after setting U_AnzVE is:29
    cout of lines after setting U_AnzPal is:30
    C:Dokumente und EinstellungenSAP_AHLokale EinstellungenTemp
    SwissAddonDebug.log
    -5002 Item no. is missing  POR1.ItemCode[line: 30]
    Ofc the item code is missing in the 20 lines I didn’t want to add!!!
    Do I do something wrong or is it a API Problem?
    regards
    Andreas

    Sorry no this is not the problem
    It all works fine with:
    if (i != 10 - 1)
        purch.Lines.Add();
    the problem is that:
    purch.Lines.UserFields.Fields.Item("U_AnzVE").Value = "100";
    is adding a line and is not setting the value.
    if u think about it in this case:
    if (i != 10 - 1)
        purch.Lines.Add();
    and
    if (i != 0)
        purch.Lines.Add();
    have the same effect
    even:
    if (i != 10 - 5)
        purch.Lines.Add();
    would have the same effect
    most important thing is that purch.Lines.Add() is left out one time in the for-loop. (well I tried it your version and it didn't work eather)
    well anyway the problem is:
    there are 30 lines if I do
    purch.Lines.UserFields.Fields.Item("U_AnzVE").Value = "100";
    purch.Lines.UserFields.Fields.Item("U_AnzPal").Value = "100";
    where there should be only 10 lines!
    I assure u It all works fine without these code-lines (but I need them:-))
    Message was edited by: Andreas Hauri

  • Add values to userfields problem

    Hello all,
    I use SBO 2004 and a try add values to fields in user table. I have a few questions:
    - when I create table and fields I use UserTableMD and UserFieldMD. I create numeric fields with editable = 10. When I see on this table and this field in Enterprise Manager this field is int type. I don't know what's up.
    oUserFieldsMD.TableName = "@wbank"
    oUserFieldsMD.Name = "saldo"
    oUserFieldsMD.Description = "Saldo konta"
    oUserFieldsMD.Type = SAPbobsCOM.BoFieldTypes.db_Numeric
    oUserFieldsMD.EditSize = 10
    lRetCode = oUserFieldsMD.Add
            If lRetCode <> 0 Then
                oCompany.GetLastError(lErrCode, sErrMsg)
                MsgBox(sErrMsg)
            Else
                MsgBox("Field: '" & oUserFieldsMD.Name & "' was added successfuly to " & oUserFieldsMD.TableName & " Table")
            End If
    - next when I try add value to field appear error:
    Inwrite KontoStr is OK, but if I will inwrite saldo_poczatkowe appear error:      "The entered value does not match the specified field type."
    saldo_poczatkowe is double type. On start I read editbox value, change "." to "," and cast it to double and inwrite in saldo_poczatkowe.
    SaldoStr = SaldoKonta.Value
    SaldoStr = CleanOutput(SaldoStr)
    saldo_poczatkowe = Val(SaldoStr)
    Try inwrite:
    oUserTable.Code = 1
    oUserTable.Name = "wyciag"
    oUserTable.UserFields.Fields.Item("U_konto").Value = KontoStr
    oUserTable.UserFields.Fields.Item("U_saldo").Value = saldo_poczatkowe I try inwrite values in all fields )            
    oUserTable.UserFields.Fields.Item
                '// add the data to the Data base
                oUserTable.Add()
                '// Check for errors
                oCompany.GetLastError(lErrCode, sErrMsg)
                If lErrCode <> 0 Then
                    MsgBox(sErrMsg)
                Else
                    MsgBox("Record saved in DB successfuly")
                End If
                oUserTable = Nothing
                System.GC.Collect()
    Mayby I do error in code? Thanks for help
    Krzysztof Sala

    Hi Krzysztof,
    I mean when you add the field the to database
    oUserFieldsMD.subType = SAPbobsCOM.BoFieldSubTypes....
    BoFldSubTypes EnumerationDescription
    Indicate special field types supported by the SAP Business One application. Use this enumeration when working with User Defined Fields.
    Members
    Member Description
    st_None  No special sub-type.  0 
    st_Address  Address format.  63 
    st_Phone  Phone format.  35 
    st_Time  Time format.  84 
    st_Rate  Double format with the system's rate accuracy.  82 
    st_Sum  Double format with the system's summery accuracy.  83 
    st_Price  Double format with the system's price accuracy.  80 
    st_Quantity  Double format with the system's quantity accuracy.  81 
    st_Percentage  Double format with the system's percentage accuracy.  37 
    st_Measurement  Double format with the system's measurement accuracy.  77 
    st_Link  Link format (mostly used for a web site links).  66 
    st_Image  Image format.  73 
    regards
    Ad

  • Adding Journal Vouchers

    Hello there,
    I am having a problem adding Journal Vouchers to SAP using the DIAPI. I have gotten everything from an "Unbalanced Transaction Error" to a "Date deviates from permissible range Error". Here is my code in VB. Please if anyone can help it would be much appreciated
    (I am reading a recordSet object to populate the fields of the journal voucher)
    ''set up the header of the journal voucher
    oJV.JournalEntries.ReferenceDate = FormatDateTime(oRecord.Fields.Item("PosDate").Value, vbShortDate)
    oJV.JournalEntries.Reference = oRecord.Fields.Item("Descr").ValidValue
    ''set up the lines of the journal entries
    syscode = oRecord.Fields.Item("SysCode").Value
    oJV.JournalEntries.Lines.SetCurrentLine(lineCount)
    oJV.JournalEntries.Lines.DueDate = FormatDateTime(oRecord.Fields.Item("PosDate").Value, vbShortDate)
    oJV.JournalEntries.Lines.ReferenceDate1 = FormatDateTime(oRecord.Fields.Item("PosDate").Value, vbShortDate)
    oJV.JournalEntries.Lines.ReferenceDate2 = FormatDateTime(oRecord.Fields.Item("PosDate").Value, vbShortDate)
    oJV.JournalEntries.Lines.VatDate = FormatDateTime(oRecord.Fields.Item("PosDate").Value, vbShortDate)
    oJV.JournalEntries.Lines.TaxDate = FormatDateTime(oRecord.Fields.Item("PosDate").Value, vbShortDate)
    oJV.JournalEntries.Lines.AccountCode = oRecord.Fields.Item("SysCode").Value
    oJV.JournalEntries.Lines.ShortName = oRecord.Fields.Item("SysCode").Value
    oJV.JournalEntries.Lines.Reference1 = oRecord.Fields.Item("Descr").Value
    If oRecord.Fields.Item("Debit").Value = 0 Then
                    oJV.JournalEntries.Lines.Credit = oRecord.Fields.Item("Credit").Value
                    oJV.JournalEntries.Lines.Debit = 0
    End If
    If oRecord.Fields.Item("Credit").Value = 0 Then
                     oJV.JournalEntries.Lines.Debit = oRecord.Fields.Item("Debit").Value
                    oJV.JournalEntries.Lines.Credit = 0
    End If
    'if need be, add a line to the journal entry
    If lineCount <> 1 Then
                    oJV.JournalEntries.Lines.Add()
    End If
    'every two lines in my record set it a journal entry
    'so check if a journal is ready to be added
    If lineCount Mod 2 <> 0 Then
    'add a journal entry to the voucher
    If oJV.JournalEntries.Add() <> 0 Then
              MessageBox.Show(oCompany.GetLastErrorDescription)
    End If
    lineCount = 0
      addedJE = True
    End If
    oRecord.MoveNext()
    If addedJE = False Then
          lineCount += 1
    End If
    End While
    ''add the journal voucher
    If oJV.Add() <> 0 Then
          MessageBox.Show(oCompany.GetLastErrorDescription)
    End If
    End Sub

    Hi guys!
    Thanks for your help.I have checked my debits and credits and I have simplified my code alot. I am able to now add a journal voucher with one journal with multiple lines. The problem seems to have been when i tried to call oJV.JournalEntries.Add(). It seems you just have to add the JournalLines and then the actual Journal Voucher.
    That is all fine but now i am having a problem setting different Posting Date (ReferenceDate on the Object), DueDate(DueDate on the Object) and Document Date (TaxDate on the Object).
    The Journal Voucher is added to SAP but all three dates are the same when in my code, i have set the Document Date to be different from the Posting Date. Could this be because I am using a Document Date of 19/12/07 and a Posting Date of 23/11/07 ( in another period)??? i dont knw. Please help if you can. My code is below :
    ''set up the lines
    syscode = oRecord.Fields.Item("SysCode").Value
    oJV.JournalEntries.Lines.SetCurrentLine(lineCount)
    ''Set Dates on lines
    oJV.JournalEntries.Lines.ReferenceDate1 = FormatDateTime(oRecord.Fields.Item("PosDate").Value, vbShortDate)
    oJV.JournalEntries.Lines.DueDate = FormatDateTime(oRecord.Fields.Item("PosDate").Value, vbShortDate)
    oJV.JournalEntries.Lines.TaxDate = FormatDateTime(oRecord.Fields.Item("DocDate").Value, vbShortDate) ''Doc Date*******
    oJV.JournalEntries.Lines.AccountCode = oRecord.Fields.Item("SysCode").Value
    oJV.JournalEntries.Lines.Reference1 = oRecord.Fields.Item("Descr").Value
    If oRecord.Fields.Item("Debit").Value = 0 Then
       oJV.JournalEntries.Lines.Credit = oRecord.Fields.Item("Credit").Value
       oJV.JournalEntries.Lines.Debit = 0
    End If
    If oRecord.Fields.Item("Credit").Value = 0
       oJV.JournalEntries.Lines.Debit = oRecord.Fields.Item("Debit").Value
       oJV.JournalEntries.Lines.Credit = 0
    End If
    oJV.JournalEntries.Lines.Add()
    oRecord.MoveNext()
    If addedJE = False Then
         lineCount += 1
    End If
    pbStatus.Value += 1
    End While
    If oJV.Add() <> 0 Then
        MessageBox.Show( oCompany.GetLastErrorDescription)
        squery = squery.Replace("'", "")
    End If
    Kind regards,
    Greeshma

  • Adding columns in system form

    Hi SBO developers!...
    I want to add columns in "document numbering" form in its load event. Someone could sugest me how to do that? I try to make it but the error is "Matrix - Line Exists" after to execute the sentence "colum.add(id,16)"in my code.
    Thanks a lot.
    It's very importan to me.
    VDM

    > As far as I know you cant make an extra row on the
    > fly if lines exist in a matrix.
    The SBO UI-help says the same.
    > I have not tried this but try adding a userfield to
    > the XYZ table. This way the new column should be
    > there always and you should be able to show and hide
    > it...
    I can confirm that, that's exatly what i'm doing. For a simple field, you get a column with an EditTexts.
    If you specify valid values, you get a column with ComboBoxes.
    Show / Hide works just like showing/hiding other matrix fields. If you want to it programmatically, you may want to have a closer look at table CPRF. I didn't figure out how to do it using the SDK.
    If anyone is interested I could post following functions:
    SetInvisible(fieldName As String, formType As String, itemId As String)
    SetVisible(fieldName As String, formType As String, itemId As String)
    Florian

  • Add userfields to document ?

    hi,
    does anybody knows how i can add userfields to documents by DI ? Some code snipets would be nice.
    thanks
    Markus

    Hi,
    You should use the object UserFieldsMD object to add userfields to a system table.
    You must know the name of the table representing your document and then follow the code I show you here:
    Dim oUserFieldsMD As SAPbobsCOM.UserFieldsMD
    '// the meta-data object needs to be initialized with a
    '// regular UserFields object
    oUserFieldsMD = pCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserFields)
    '// Setting the Field's mandatory properties
    oUserFieldsMD.TableName = "TABLENAME"
    oUserFieldsMD.Name = "MyFieldName"
    oUserFieldsMD.Description = "My Field Description"
    oUserFieldsMD.Type = SAPbobsCOM.BoFieldTypes.db_Alpha
    oUserFieldsMD.EditSize = 20
    '// Adding the Field to the Table
    lRetCode = oUserFieldsMD.Add
    Hope it helps
    Trinidad.

  • Adding Invoices into SAP Business One via web service.

    Hello!
    I am partially done with my project. However, I am down to a couple of problems which hinders the progress of my project.
    When I create an invoice with 2 items it will be inserted perfectly into the SAP Business One. However, when a second invoice with another 2 items is created the newly inserted invoice will reflect 4 items. 2 from the first invoice and the remaining 2 from the current invoice.
    May I know what is the problem? I have been debugging for the past 2 nights and i couldn't find any headways.
    Your help will be greatly appreciated.
    Thank you!
    Here are the codes:
                    oCompany = Session("g_CompanyConnection")
                    oDocument = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oInvoices)
                    oDocument.DocType = SAPbobsCOM.BoDocumentTypes.dDocument_Items
                    oRecSet = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)
                    oPay = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oIncomingPayments)
                    drOrdHeader = dtOrdHeader.Rows(0)
                    'Set values to the fields
                    oDocument.CardCode = drOrdHeader("CardCode")
                    oDocument.HandWritten = SAPbobsCOM.BoYesNoEnum.tNO
                    Dim j As Integer = 0
                    Dim count As Integer = 0
                    While dtOrdLines.Rows.Count > j
                        drOrdLines = dtOrdLines.Rows(j)
                        If count > 0 Then
                            oDocument.Lines.Add()
                        End If
                        'item lines - set value to the first line
                        oDocument.Lines.ItemCode = drOrdLines("ItemCode").ToString()
                        oDocument.Lines.Price = drOrdLines("Price").ToString()
                        oDocument.Lines.Quantity = drOrdLines("Quantity").ToString()
                        count = count + 1
                        j = j + 1
                    End While
                    lngRetVal = oDocument.Add

    Thanks for your reply Li!
    dtOrdLines was all along set as a local variable. Perhaps i should show the whole chuck of codes here.
    Public Function CreateItemOrder(ByVal OrderDataSet As DataSet) As String
            Dim lngRetVal As Long
            Dim retVal As Long
            Dim strReturn As String = ""
            Dim strReturn1 As String = ""
            Dim oDocument As SAPbobsCOM.Documents = Nothing
            'Dim oUDF As SAPbobsCOM.UserFields
            Dim dtOrdHeader As DataTable = Nothing
            Dim dtOrdLines As DataTable = Nothing
            Dim dtPayment As DataTable = Nothing
            Dim drOrdHeader As DataRow
            Dim drOrdLines As DataRow
            Dim drPayment As DataRow
            Dim oCompany As SAPbobsCOM.Company
            Dim oRecSet As SAPbobsCOM.Recordset
            Dim oPay As SAPbobsCOM.Payments
            Dim IngRow As Long = 0
            Try
                SetConnectionParam("S10033973", "SBO_Innova", "manager", "manager", "sa", "P@ssw0rd")
                dtOrdHeader = OrderDataSet.Tables("OnlySalesInvoice")
                dtOrdLines = OrderDataSet.Tables("OnlyInvoiceItem")
                dtPayment = OrderDataSet.Tables("PaymentTerm")
                If ConnectToDatabase() Then
                    oCompany = Session("g_CompanyConnection")
                    oDocument = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oInvoices)
                    oDocument.DocType = SAPbobsCOM.BoDocumentTypes.dDocument_Items
                    oRecSet = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)
                    oPay = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oIncomingPayments)
                    drOrdHeader = dtOrdHeader.Rows(0)
                    'Set values to the fields
                    oDocument.CardCode = drOrdHeader("CardCode")
                    'oDocument.DocDueDate = Today
                    'oDocument.Address2 = drOrdHeader("ShipTo")
                    'oDocument.Address = drOrdHeader("BillTo")
                    'oDocument.DocDate = Today
                    'oDocument.CardName = drOrdHeader("CardName").ToString()
                    oDocument.HandWritten = SAPbobsCOM.BoYesNoEnum.tNO
                    Dim j As Integer = 0
                    Dim count As Integer = 0
                    While dtOrdLines.Rows.Count > j
                        drOrdLines = dtOrdLines.Rows(j)
                        If count > 0 Then
                            oDocument.Lines.Add()
                        End If
                        'item lines - set value to the first line
                        oDocument.Lines.ItemCode = drOrdLines("ItemCode").ToString()
                        'oDocument.Lines.LineTotal = drOrdLines("LineTotal").ToString()
                        'oDocument.Lines.ItemDescription = drOrdLines("Desc").ToString()
                        oDocument.Lines.Price = drOrdLines("Price").ToString()
                        oDocument.Lines.Quantity = drOrdLines("Quantity").ToString()
                        count = count + 1
                        j = j + 1
                    End While
                    Dim k As Integer = 0
                    Dim count1 As Integer = 0
                    While dtPayment.Rows.Count > k
                        drPayment = dtPayment.Rows(k)
                        oPay.CardCode = drOrdHeader("CardCode")
                        oPay.CashSum = 0
                        oPay.TransferAccount = "161016"
                        oPay.TransferSum = 0
                        oPay.Checks.CheckSum = drPayment("Price") - drPayment("Change")
                        oPay.Checks.BankCode = drPayment("BankCode")
                        k = k + 1
                    End While
                    retVal = oPay.Add()
                    If retVal = 0 Then
                        Session("g_LastErrorMsg") = " "
                        oCompany.GetNewObjectCode(strReturn1) 'get last doc
                    Else
                        Session("g_LastErrorMsg") = oCompany.GetLastErrorDescription
                    End If
                    lngRetVal = oDocument.Add '<----- the same document is added here, here is where the document should actually be added
                    'Check the result
                    If lngRetVal = 0 Then
                        Session("g_LastErrorMsg") = " "
                        oCompany.GetNewObjectCode(strReturn) 'get last doc
                    Else
                        Session("g_LastErrorMsg") = oCompany.GetLastErrorDescription
                    End If
                    oRecSet.DoQuery("UPDATE OINV Set ReceiptNum = " & strReturn1 & " Where DocEntry=" & strReturn)
                    'oRecSet.DoQuery("UPDATE OINV SET PaidToDate = ")
                    oRecSet.DoQuery("UPDATE OINV SET IsICT = 'Y' WHERE IsICT =" & strReturn)
                End If
            Catch ex As Exception
                Session("g_LastErrorMsg") = ex.Message
                strReturn = ex.Message.ToString()
            Finally
                oDocument = Nothing
            End Try
            Return strReturn
        End Function

Maybe you are looking for

  • ORA-00604: error occurred at recursive SQL level 1 (Call to a Oracle View)

    I have created a view that refers to a package function within the sql select. Like E.x CREATE OR REPLACE VIEW VW_TAX as select test_pkg.fn_get_gl_value(acct_id) desired_col1, test_pkg.fn_get_gl_desc_value(acct_id) desired_col2 From tables a, b a.col

  • How can i transfer music from my computer to my ipod?

    how can i transfer music from my computer to my ipod?

  • Doubts in BW Purchasing

    Hi all: I need some inputs form you all. I have some doubts in Vendor Otif in MM-Purchasing. 1.What are all the infocoube,ods,infosource,datasource required to use for vendor otif?.I expect in technical wise. 2.Do u have any document how vendor otif

  • Context Menu (or right button click) does not appear menu-window

    The context menu does not appear in some browser sections. If I run browser in safe mode it works without problem. I've tried to reinstall firefox, after uninstall I also manualy deleted all rest hidden and visible folders - did not help. Also I trie

  • Surpress GET PERNR?

    How do I suppress the GET PERNR event? I have a report where I do a table dump of T710 or output PA0008 based upon TAB selection. However, I want to prevent performance problem when I just want to dump T710 table. The GET PERNR event seems to output