Click here to Skip to main content
15,888,984 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I need to update two custom field in some invoices (I created this field in customer custom fields first uuid second filed uuid2 ) and i have not been able to figure out how to update it using c#. how can i update QuickBooks Desktop Custom Fields Data using the QBFC SDK i tried this
//create class invoice

 public class Invoice
{
    public string InvoiceNumber { get; set; }
    public string Item { get; set; }
    public string TxnDate { get; set; }
    public double Quantity { get; set; }
    public string ItemCode { get; set; }
    public string ItemDescription { get; set; }
    public string Note { get; set; }
    public string UpcCode { get; set; }
    public string UnitPrice { get; set; }
    public string TotalPrice { get; set; }
    public string PerUnit { get; set; }
    //
    public string CustomerName { get; set; }
    public string BillAddressAdd1 { get; set; }
    public string BillAddressAdd2 { get; set; }
    public string BillAddressCity { get; set; }
    public string BillAddressState { get; set; }
    public string BillAddressPostalCode { get; set; }
    public string Phone { get; set; }
    public string Fax { get; set; }
    public string Memo { get; set; }
    public string ListId { get; set; }
    public string EditSequence { get; set; }
    public string OwnerID { get; set; }
    public string uuid { get; set; }
    public string uuid2 { get; set; }
    

}
//create function UpdateINVOICE
<pre>enter code here public bool UpdateINVOICE(Invoice invoice)
    {
        try
        {
            sessionManager = new QBSessionManager();

            IMsgSetRequest requestMsgSet = sessionManager.CreateMsgSetRequest(countryQB, majorVersionQB, minorVersionQB);
          
            requestMsgSet.Attributes.OnError = ENRqOnError.roeContinue;
            IInvoiceMod invoiceModRq = requestMsgSet.AppendInvoiceModRq();
            IDataExtAdd DataExtAddRq = requestMsgSet.AppendDataExtAddRq();
         DataExtAddRq.OwnerID.SetValue("0"); 
                               
                            if (invoice.Memo != null)
                invoiceModRq.Memo.SetValue(invoice.Memo);
            if (invoice.ListId != null)
                invoiceModRq.TxnID.SetValue(invoice.ListId);
            if (invoice.EditSequence != null)
                invoiceModRq.EditSequence.SetValue(invoice.EditSequence);
            DataExtAddRq.ORListTxnWithMacro.ListDataExt.ListDataExtType.SetValue(ENListDataExtType.ldetCustomer);
            DataExtAddRq.ORListTxnWithMacro.ListDataExt.ListObjRef.FullName.SetValue("cust1");
          
            DataExtAddRq.DataExtName.SetValue("uuid"); 
         DataExtAddRq.DataExtValue.SetValue(invoice.uuid);
               DataExtAddRq.DataExtName.SetValue("uuid2"); 
            DataExtAddRq.DataExtValue.SetValue(invoice.uuid2);
            OpenConnection();
            IMsgSetResponse responseMsgSet = sessionManager.DoRequests(requestMsgSet);
            
            CloseConnection();
           IResponse response = responseMsgSet.ResponseList.GetAt(0);
           

            if (response.StatusCode != 0)
            {
                throw new Exception($" Error: {response.StatusMessage}");
               
            }

            return true;

        }
        catch (Exception)
        {
            throw;
        }
        finally
        {
            CloseConnection();
        }
    }

Custom fields can't update
The problem is that the previous code does not work. He cannot update the uuid and uuid2 fields, although he can update the memo field. I think the reason is that I am trying to update the custom fields data for customers. Is there a better way than the previous code or what is the error in my code?

What I have tried:

The problem is that the previous code does not work. He cannot update the uuid and uuid2 fields, although he can update the memo field. I think the reason is that I am trying to update the custom fields data for customers. Is there a better way than the previous code or what is the error in my code?
Posted
Updated 6-Nov-21 4:57am
v3
Comments
Richard MacCutchan 6-Nov-21 10:45am    
You have posted the same code multiple times, some unformatted, and some formatted. Please use the Improve question link above, and remove the duplicates, ensure the remainder is correctly formatted, and explain exactly what the problem is.
michael nabil 6-Nov-21 11:04am    
thanks

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900