Method Community

 

API General Question

Last post 08-17-2012 8:44 AM by Method_David. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • 08-15-2012 7:07 AM

    API General Question

    Hi Guys,

     

    I have a weird issue here. I'm creating a customer through the API - The Result is Success with a Record_ID as a value.

    I then immediately try to obtain the customer through that Record_ID and I'm getting back NULL. Only after I Sync Method with QuickBooks I can retrieve the customer.

    Am I doing something wrong here? I was under the impression that when I pull a record it comes directly from Method, whether it’s synced or not.

    Thanks,

    Nick

     

  • 08-15-2012 8:53 AM In reply to

    Re: API General Question

    Hi nick_warren,

    I need to specify. The field returned is RecordID not Record_ID. If you have a custom field called Record_ID and are trying to retrieve that, it may not be populated if you don't populate it during the insert.

    Let's walkthrough a quick simple example of what you're doing. At no point will I sync with quickbooks. The example is in C# and assumes you already have the appropriate service references added.

    Step 1. Add the new customer. Two fields are required. Name and Contact. I will use DaveCustomer and DaveContact for their respective values.

        string[ arrInsertFieldsArray = new string[ { "Name", "Contact" };

        string[ arrInsertValueArray = new string[ { "DaveCustomer", "DaveContact" };

        lblMethodAPIInsertV2.Text = _MethodAPI.MethodAPIInsertV2(CompanyAccount, Login, Password, "", "Customer", arrInsertFieldsArray, arrInsertValueArray)

    In my case, I'm writing the values to a label. At this point my label text is

    <?xml version="1.0" encoding="windows-1252" ?><MethodAPI response = "SuccessSendToDesktop" RecordID="163" ></MethodAPI>

    Step 2. Parse the xml to get the recordid (in this case 163).

    How you do that is up to you.

    Step 3. Retrieve Customer with RecordID 163 from your account

    Using MethodAPISelect_DataSetV2 (Don't forget you need to pass in a dataset by ref, where the record will be returned)

         System.Data.DataSet ReturnDS = null;        

         lblMethodAPISelect_DataSetV2.Text = _MethodAPI.MethodAPISelect_DataSetV2(CompanyAccount, Login, Password, "", ref ReturnDS, "Customer", "RecordID, Name", "RecordID = 163", "", "", "");

         //ReturnDS now has a datatable with one record in it

    Using MethodAPISelect_XMLV2

        lblMethodAPISelect_XMLV2.Text = _MethodAPI.MethodAPISelect_XMLV2(CompanyAccount, Login, Password, "", "Customer", "RecordID, Name", "RecordID = 163", "", "", "")

        //lblMethodAPISelect_XMLV2.Text is now <?xml version="1.0" encoding="windows-1252" ?><MethodAPI response = "Success" MaxRecords= "False"><MethodIntegration Table='Customer'> <Record> <RecordID>163</RecordID> <Name>DaveCustomer2</Name> </Record> </MethodIntegration></MethodAPI>

     

    At no point has a quickbooks sync been done. But I have successfully added and retrieved a customer via the API

     

    Dave

     

     

     

  • 08-15-2012 11:33 AM In reply to

    Re: API General Question

    Dave - I was referring to the RecordID, yes. 

    I'm doing it exactly as you said but its not working. I will try to debug it and will post exactly the result.

  • 08-16-2012 3:54 AM In reply to

    Re: API General Question

    Ok Dave – I figured out what the issue is but I have no idea how to fix it.

    1)      I insert a Customer and Estimate through the API.

    2)      I use DataSetV2 to retrieve the Estimate back.

      1. At this point, the estimate “Billing” information is empty – Fields: BillAddressAddr1, BillAddressAddr2, BillAddressAddr3, BillAddressAddr4, BillAddressAddr5, BillAddressCity, BillAddressState, BillAddressPostalCode, BillAddressNote, return as blank. I also tried query the specific RecordID through your API directly, same result – empty.

    3)      If I Sync Method with QuickBooks – Method suddenly has the Billing Address fields populated and I can retrieve the Estimate back.

     

    I checked Method itself PRIOR of Syncing and right after “Phase (1)”. The billing address inside the Estimate is indeed empty. The “Customer” field is populated properly and has all the Billing and Shipping information in it. Please see attached image –

     

    When clicking inside Method on the customer’s name, suddenly the address fields populate and all the information is there. Please see attached image –

     

     I’m assuming this is what I’m experiencing. For some reason clicking the customer or alternatively, syncing with QuickBooks re-populates the address fields.

    Moreover, the Sales Tax field should be populated on the Estimate (As it does when you Sync to QuickBooks), it does not populate automatically within Method. Again, there is inconsistency here.

    My problem starts when I try to pull out the Billing information from the Estimate itself prior of Syncing / Clicking the customer’s name inside Method – this query will return an empty result both for the sales tax and for the address although ALL the information is inside Method already.

  • 08-17-2012 8:44 AM In reply to

    Re: API General Question

    Answer

    Hi Nick_warren,

    There is no inconsistency here. The fields you populated via the API are what is populated in Method.

    I think what is confusing you here, is that there are events on the the customer dropdown. In particular you should look at the textchanged event of the dropdown. When this fires the address fields that you mention are populated.

    If you want them to populate via the api you should include them in your API insert.

    Dave


Page 1 of 1 (5 items)