Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Quickbooks CustomFields blues
Message
 
À
06/01/2015 13:11:40
Information générale
Forum:
ASP.NET
Catégorie:
XML
Versions des environnements
Environment:
C# 4.0
OS:
Windows Server 2012
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Desktop
Divers
Thread ID:
01613140
Message ID:
01613177
Vues:
42
So I tried this :
        MessageBox.Show(string.Format("Field customer id {0} : {1}", customerId, fieldsRaw));
        XDocument xFields = XDocument.Parse(fieldsRaw);
        var fields = from xField in xFields.Descendants("CustomerField")
                          select new
                           {
                                    isoCode  = xField.Element("Country Isocode").Value,
                                    companyNr = xField.Element("Company Nr").Value,                             
                            };
but it breaks at
XDocument xFields = XDocument.Parse(fieldsRaw);
with the exception that "there are multiple root elements" at line 1 position 74.

I'm just using the rssBus Odbc driver for Quickbooks applied to a desktop version.

fieldsRaw is what I get back from this method (with raw = true)
       internal static string getCustomfields(string customerId, OdbcConnection conn, bool raw = false)
        {
            string sql = "select CustomFields from Customers where Id ='" + customerId + "'";
            string fieldRaw = (string)new OdbcCommand(sql, conn).ExecuteScalar();
            if (raw) { return fieldRaw; }
            return fieldRaw;
        }
I am able to "decode" the strings using the "brute force". I'm holding my breath now as I have to encode and wirte the custom fields against the quickbooks db :)

>>>>I get this raw string (see attached) when I draw up the customFields in the customers table of quickbooks. Is there a "best practices" way to decode/encode this into/from a customFieldsObject{string countryIsocode; string companyId}, or is it ok if use "brute force" string manipulations in this instance.
>>>>
>>>>And is it just me, or this _not_ a well formed xml, there should be (at least) encapsulating customFields tags no, for this to be submitted to xml encoding/decoding routines.
>>>
>>>I typically use the XDocument and XElement classes to parse the QuickBooks XML. It does appear to be well formed XML. The CustomField element contains Name and Value elements. The CustomField element can repeat. As far as I know repeating elements do not need to be enclosed in a separate structure.
>>
>>Hi Rob, many thanks for your answer.
>>
>>I did try it what you suggested, it would be my preferred approach, but it complained that "the root is not unique". which is why I had my doubt about the well formedness of the xml.
>
>Is that string the entire set of data you are getting back from QuickBooks? And what interface are you using to get the data? It looks like you are probably using the QuickBooks Online API. If you are using the raw XML, based off of the documentation at https://developer.intuit.com/docs/0100_accounting/0300_developer_guides/custom_fields, there should be an enclosing IntuitResponse element you can parse. If you are using their .NET SDK, the custom fields should be a property available when you load the customer based off of https://developer.intuit.com/docs/0100_accounting/0500_developer_kits/0150_ipp_.net_devkit_3.0/custom_fields.
>
>If nothing else, you could enclose it in a custom root element in order to parse it.

If things have the tendency to go your way, do not worry. It won't last. Jules Renard.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform