Rajkumar
Rajkumar

Reputation: 257

Sort Customer response in ascending order, quickbooks online PHP API

Downloaded the code from http://consolibyte.com/downloads/quickbooks-php-devkit/

Below is the code, i am using to retrive Customer in Ascending Order

$Service = new QuickBooks_IPP_Service_Customer();

if ($creds['qb_flavor'] == QuickBooks_IPP_IDS::FLAVOR_ONLINE)
{
    $query = array('Sort' => 'LastUpdatedTime OldestToNewest');
}

$page = 1;
$limit = 25;
$list = $Service->findAll($Context, $realm, $query, $page, $limit);
print_r($Service);print_r($list);die;

Response:

QuickBooks_IPP_Service_Customer Object ( [_last_request:protected] => POST https://qbo.intuit.com/qbo32/resource/customers/v2/739135155 HTTP/1.1 Content-Type: application/x-www-form-urlencoded Authorization: OAuth realm="", oauth_signature_method="HMAC-SHA1", oauth_signature="aYDo4x%2BzncJu5zr0E9qthrzjJGg%3D", oauth_nonce="I06pZ", oauth_timestamp="1375681233", oauth_token="qyprdrTTlD08zozgugfGLF1R3agdRB2U3TYEUdhhPPLGOZzq", oauth_consumer_key="qyprdvBrNnwXryRrxd1ElZxVikvNG3", oauth_version="1.0" Content-Length: 63

PageNum=1&ResultsPerPage=25&Sort=LastUpdatedTime+OldestToNewest [_last_response:protected] => HTTP/1.1 400 Bad Request Date: Mon, 05 Aug 2013 05:40:34 GMT Server: Apache Set-Cookie: qboeuid=10.129.32.5.1375681234314737; path=/; expires=Tue, 05-Aug-14 05:40:34 GMT; domain=.intuit.com Vary: Accept-Encoding Content-Encoding: gzip Content-Length: 248 Connection: close Content-Type: application/xml

<?xml version="1.0" encoding="UTF-8" standalone="yes"?><FaultInfo xmlns="http://www.intuit.com/sb/cdm/baseexceptionmodel/xsd"><Message>Invalid Property Name in Sort Criteria: LastUpdatedTime </Message><ErrorCode>BAD_QUERY_REQUEST</ErrorCode><Cause>QUERY_INVALID_SORT_CRITERIA</Cause></FaultInfo> [_last_debug:protected] => Array ( [QuickBooks_IPP] => Array ( [http_request_response_duration] => 1.5505950450897 )

    )

[_flavor:protected] =&gt; 
[_errcode:protected] =&gt; 0
[_errtext:protected] =&gt; 
[_errdetail:protected] =&gt; 

)

Customer Response:

<!--?xml version="1.0" encoding="UTF-8" standalone="yes"?--><qbo:searchresults xmlns="http://www.intuit.com/sb/cdm/v2" xmlns:qbp="http://www.intuit.com/sb/cdm/qbopayroll/v1" xmlns:qbo="http://www.intuit.com/sb/cdm/qbo"><qbo:cdmcollections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="Customers"><customer><id iddomain="QBO">15</id><synctoken>1</synctoken><metadata><createtime>2013-07-10T08:35:33-07:00</createtime><lastupdatedtime>2013-08-03T06:56:11-07:00</lastupdatedtime></metadata><name>Brown Elizabeth CON11</name><address><line1>123 Anywhere Street</line1><city>San Jose</city><country>USA</country><countrysubdivisioncode>CA</countrysubdivisioncode><postalcode>99999</postalcode><geocode>INVALID</geocode><tag>Billing</tag></address><phone><devicetype>Primary</devicetype><freeformnumber>(162) 938-2491</freeformnumber></phone><phone><devicetype>Mobile</devicetype><freeformnumber>(704) 297-3005</freeformnumber></phone><website><email><address>[email protected]</address></email><givenname>Elizabeth</givenname><familyname>Brown</familyname><customfield xsi:type="BooleanTypeCustomField"><definitionid>Bill With Parent</definitionid><value>false</value></customfield><customfield xsi:type="StringTypeCustomField"><definitionid>Preferred Delivery Method</definitionid><value>EMAIL</value></customfield><showas>Brown Elizabeth CON11</showas><openbalance><amount>0</amount></openbalance></website></customer><customer><id iddomain="QBO">16</id><synctoken>1</synctoken><metadata><createtime>2013-07-10T08:35:36-07:00</createtime><lastupdatedtime>2013-08-06T00:22:56-07:00</lastupdatedtime></metadata><name>Davis Jennifer CON12</name><address><line1>123 Anywhere Street</line1><city>San Jose</city><country>USA</country><countrysubdivisioncode>CA</countrysubdivisioncode><postalcode>99999</postalcode><geocode>INVALID</geocode><tag>Billing</tag></address><phone><devicetype>Primary</devicetype><freeformnumber>(415) 668-0506</freeformnumber></phone><phone><devicetype>Mobile</devicetype><freeformnumber>(321) 403-8057</freeformnumber></phone><website><email><address>[email protected]</address></email><givenname>Jennifer</givenname><familyname>Davis</familyname><customfield xsi:type="BooleanTypeCustomField"><definitionid>Bill With Parent</definitionid><value>false</value></customfield><customfield xsi:type="StringTypeCustomField"><definitionid>Preferred Delivery Method</definitionid><value>EMAIL</value></customfield><showas>Davis Jennifer CON12</showas><openbalance><amount>528</amount></openbalance></website></customer><customer><id iddomain="QBO">12</id><synctoken>1</synctoken><metadata><createtime>2013-07-10T08:35:26-07:00</createtime><lastupdatedtime>2013-08-03T06:56:19-07:00</lastupdatedtime></metadata><name>Johnson Patricia CON13</name><address><line1>345 Sugar Blvd.</line1><city>San Francisco</city><country>USA</country><countrysubdivisioncode>CA</countrysubdivisioncode><postalcode>99999</postalcode><geocode>LAT=37.8887062,LNG=-122.4587342</geocode><tag>Billing</tag></address><phone><devicetype>Primary</devicetype><freeformnumber>(728) 984-9068</freeformnumber></phone><phone><devicetype>Mobile</devicetype><freeformnumber>(111) 598-3326</freeformnumber></phone><website><email><address>[email protected]</address></email><givenname>Patricia</givenname><familyname>Johnson</familyname><customfield xsi:type="BooleanTypeCustomField"><definitionid>Bill With Parent</definitionid><value>false</value></customfield><customfield xsi:type="StringTypeCustomField"><definitionid>Preferred Delivery Method</definitionid><value>EMAIL</value></customfield><showas>Johnson Patricia CON13</showas><openbalance><amount>0</amount></openbalance></website></customer><customer><id iddomain="QBO">22</id><synctoken>0</synctoken><metadata><createtime>2013-08-03T06:58:43-07:00</createtime><lastupdatedtime>2013-08-03T06:58:43-07:00</lastupdatedtime></metadata><name>Johnson Patricia CON2</name><address><line1>345 Sugar Blvd.</line1><city>San Francisco</city><country>USA</country><countrysubdivisioncode>CA</countrysubdivisioncode><postalcode>99999</postalcode><geocode>LAT=37.8887062,LNG=-122.4587342</geocode><tag>Billing</tag></address><phone><devicetype>Primary</devicetype><freeformnumber>(728) 984-9068</freeformnumber></phone><phone><devicetype>Mobile</devicetype><freeformnumber>(111) 598-3326</freeformnumber></phone><website><email><address>[email protected]</address></email><givenname>Patricia</givenname><familyname>Johnson</familyname><customfield xsi:type="BooleanTypeCustomField"><definitionid>Bill With Parent</definitionid><value>false</value></customfield><customfield xsi:type="StringTypeCustomField"><definitionid>Preferred Delivery Method</definitionid><value>EMAIL</value></customfield><showas>Johnson Patricia CON2</showas><openbalance><amount>0</amount></openbalance></website></customer><customer><id iddomain="QBO">14</id><synctoken>1</synctoken><metadata><createtime>2013-07-10T08:35:31-07:00</createtime><lastupdatedtime>2013-08-03T06:56:23-07:00</lastupdatedtime></metadata><name>Jones Barbara CON14</name><address><line1>123 Anywhere Street</line1><city>San Francisco</city><country>USA</country><countrysubdivisioncode>CA</countrysubdivisioncode><postalcode>99999</postalcode><geocode>INVALID</geocode><tag>Billing</tag></address><phone><devicetype>Primary</devicetype><freeformnumber>(237) 024-7627</freeformnumber></phone><phone><devicetype>Mobile</devicetype><freeformnumber>(841) 775-2009</freeformnumber></phone><website><email><address>[email protected]</address></email><givenname>Barbara</givenname><familyname>Jones</familyname><customfield xsi:type="BooleanTypeCustomField"><definitionid>Bill With Parent</definitionid><value>false</value></customfield><customfield xsi:type="StringTypeCustomField"><definitionid>Preferred Delivery Method</definitionid><value>EMAIL</value></customfield><showas>Jones Barbara CON14</showas><openbalance><amount>0</amount></openbalance></website></customer><customer><id iddomain="QBO">24</id><synctoken>0</synctoken><metadata><createtime>2013-08-03T06:59:30-07:00</createtime><lastupdatedtime>2013-08-03T06:59:30-07:00</lastupdatedtime></metadata><name>Jones Barbara CON4</name><address><line1>123 Anywhere Street</line1><city>San Francisco</city><country>USA</country><countrysubdivisioncode>CA</countrysubdivisioncode><postalcode>99999</postalcode><geocode>INVALID</geocode><tag>Billing</tag></address><phone><devicetype>Primary</devicetype><freeformnumber>(237) 024-7627</freeformnumber></phone><phone><devicetype>Mobile</devicetype><freeformnumber>(841) 775-2009</freeformnumber></phone><website><email><address>[email protected]</address></email><givenname>Barbara</givenname><familyname>Jones</familyname><customfield xsi:type="BooleanTypeCustomField"><definitionid>Bill With Parent</definitionid><value>false</value></customfield><customfield xsi:type="StringTypeCustomField"><definitionid>Preferred Delivery Method</definitionid><value>EMAIL</value></customfield><showas>Jones Barbara CON4</showas><openbalance><amount>0</amount></openbalance></website></customer><customer><id iddomain="QBO">17</id><synctoken>1</synctoken><metadata><createtime>2013-07-10T08:35:39-07:00</createtime><lastupdatedtime>2013-08-03T06:56:28-07:00</lastupdatedtime></metadata><name>Miller Maria CON15</name><address><line1>1715 Scott Dr</line1><city>San Mateo</city><country>USA</country><countrysubdivisioncode>CA</countrysubdivisioncode><postalcode>99999</postalcode><geocode>LAT=37.5662478,LNG=-122.2883717</geocode><tag>Billing</tag></address><phone><devicetype>Primary</devicetype><freeformnumber>(968) 916-1248</freeformnumber></phone><phone><devicetype>Mobile</devicetype><freeformnumber>(075) 401-6608</freeformnumber></phone><website><email><address>[email protected]</address></email><givenname>Maria</givenname><familyname>Miller</familyname><customfield xsi:type="BooleanTypeCustomField"><definitionid>Bill With Parent</definitionid><value>false</value></customfield><customfield xsi:type="StringTypeCustomField"><definitionid>Preferred Delivery Method</definitionid><value>EMAIL</value></customfield><showas>Miller Maria CON15</showas><openbalance><amount>0</amount></openbalance></website></customer><customer><id iddomain="QBO">23</id><synctoken>0</synctoken><metadata><createtime>2013-08-03T06:59:09-07:00</createtime><lastupdatedtime>2013-08-06T00:23:13-07:00</lastupdatedtime></metadata><name>Miller Maria CON7</name><address><line1>1715 Scott Dr</line1><city>San Mateo</city><country>USA</country><countrysubdivisioncode>CA</countrysubdivisioncode><postalcode>99999</postalcode><geocode>LAT=37.5662478,LNG=-122.2883717</geocode><tag>Billing</tag></address><phone><devicetype>Primary</devicetype><freeformnumber>(968) 916-1248</freeformnumber></phone><phone><devicetype>Mobile</devicetype><freeformnumber>(075) 401-6608</freeformnumber></phone><website><email><address>[email protected]</address></email><givenname>Maria</givenname><familyname>Miller</familyname><customfield xsi:type="BooleanTypeCustomField"><definitionid>Bill With Parent</definitionid><value>false</value></customfield><customfield xsi:type="StringTypeCustomField"><definitionid>Preferred Delivery Method</definitionid><value>EMAIL</value></customfield><showas>Miller Maria CON7</showas><openbalance><amount>10</amount></openbalance></website></customer><customer><id iddomain="QBO">19</id><synctoken>1</synctoken><metadata><createtime>2013-07-10T08:35:43-07:00</createtime><lastupdatedtime>2013-08-03T06:56:32-07:00</lastupdatedtime></metadata><name>Moore Margaret CON16</name><address><line1>123 Anywhere Street</line1><city>San Francisco</city><country>USA</country><countrysubdivisioncode>CA</countrysubdivisioncode><postalcode>99999</postalcode><geocode>INVALID</geocode><tag>Billing</tag></address><phone><devicetype>Primary</devicetype><freeformnumber>(381) 260-9729</freeformnumber></phone><phone><devicetype>Mobile</devicetype><freeformnumber>(731) 228-7024</freeformnumber></phone><website><email><address>[email protected]</address></email><givenname>Margaret</givenname><familyname>Moore</familyname><customfield xsi:type="BooleanTypeCustomField"><definitionid>Bill With Parent</definitionid><value>false</value></customfield><customfield xsi:type="StringTypeCustomField"><definitionid>Preferred Delivery Method</definitionid><value>EMAIL</value></customfield><showas>Moore Margaret CON16</showas><openbalance><amount>0</amount></openbalance></website></customer><customer><id iddomain="QBO">21</id><synctoken>0</synctoken><metadata><createtime>2013-08-03T06:58:21-07:00</createtime><lastupdatedtime>2013-08-03T06:58:21-07:00</lastupdatedtime></metadata><name>Moore Margaret CON9</name><address><line1>123 Anywhere Street</line1><city>San Francisco</city><country>USA</country><countrysubdivisioncode>CA</countrysubdivisioncode><postalcode>99999</postalcode><geocode>INVALID</geocode><tag>Billing</tag></address><phone><devicetype>Primary</devicetype><freeformnumber>(381) 260-9729</freeformnumber></phone><phone><devicetype>Mobile</devicetype><freeformnumber>(731) 228-7024</freeformnumber></phone><website><email><address>[email protected]</address></email><givenname>Margaret</givenname><familyname>Moore</familyname><customfield xsi:type="BooleanTypeCustomField"><definitionid>Bill With Parent</definitionid><value>false</value></customfield><customfield xsi:type="StringTypeCustomField"><definitionid>Preferred Delivery Method</definitionid><value>EMAIL</value></customfield><showas>Moore Margaret CON9</showas><openbalance><amount>0</amount></openbalance></website></customer><customer><id iddomain="QBO">11</id><synctoken>1</synctoken><metadata><createtime>2013-07-10T08:35:23-07:00</createtime><lastupdatedtime>2013-08-03T06:56:36-07:00</lastupdatedtime></metadata><name>Smith Mary CON17</name><address><line1>1715 Scott Dr</line1><city>Sunnyvale</city><country>USA</country><countrysubdivisioncode>CA</countrysubdivisioncode><postalcode>99999</postalcode><geocode>LAT=37.3681306,LNG=-122.0306042</geocode><tag>Billing</tag></address><phone><devicetype>Primary</devicetype><freeformnumber>(077) 885-6854</freeformnumber></phone><phone><devicetype>Mobile</devicetype><freeformnumber>(721) 945-7563</freeformnumber></phone><website><email><address>[email protected]</address></email><givenname>Mary</givenname><familyname>Smith</familyname><customfield xsi:type="BooleanTypeCustomField"><definitionid>Bill With Parent</definitionid><value>false</value></customfield><customfield xsi:type="StringTypeCustomField"><definitionid>Preferred Delivery Method</definitionid><value>EMAIL</value></customfield><showas>Smith Mary CON17</showas><openbalance><amount>0</amount></openbalance></website></customer><customer><id iddomain="QBO">25</id><synctoken>1</synctoken><metadata><createtime>2013-08-03T07:00:59-07:00</createtime><lastupdatedtime>2013-08-03T07:29:37-07:00</lastupdatedtime></metadata><name>Taylor Dorothy CON10</name><address><line1>1715 Scott Dr</line1><city>San Francisco</city><country>USA</country><countrysubdivisioncode>CA</countrysubdivisioncode><postalcode>99999</postalcode><geocode>LAT=37.7858312,LNG=-122.4382959</geocode><tag>Billing</tag></address><phone><devicetype>Primary</devicetype><freeformnumber>(175) 329-7081</freeformnumber></phone><phone><devicetype>Mobile</devicetype><freeformnumber>(935) 444-1766</freeformnumber></phone><website><email><address>[email protected]</address></email><givenname>Dorothy</givenname><familyname>Taylor 1</familyname><customfield xsi:type="BooleanTypeCustomField"><definitionid>Bill With Parent</definitionid><value>false</value></customfield><customfield xsi:type="StringTypeCustomField"><definitionid>Preferred Delivery Method</definitionid><value>EMAIL</value></customfield><showas>Taylor Dorothy CON10</showas><openbalance><amount>0</amount></openbalance></website></customer><customer><id iddomain="QBO">20</id><synctoken>1</synctoken><metadata><createtime>2013-07-10T08:35:46-07:00</createtime><lastupdatedtime>2013-08-03T06:56:40-07:00</lastupdatedtime></metadata><name>Taylor Dorothy CON18</name><address><line1>1715 Scott Dr</line1><city>San Francisco</city><country>USA</country><countrysubdivisioncode>CA</countrysubdivisioncode><postalcode>99999</postalcode><geocode>LAT=37.7858312,LNG=-122.4382959</geocode><tag>Billing</tag></address><phone><devicetype>Primary</devicetype><freeformnumber>(175) 329-7081</freeformnumber></phone><phone><devicetype>Mobile</devicetype><freeformnumber>(935) 444-1766</freeformnumber></phone><website><email><address>[email protected]</address></email><givenname>Dorothy</givenname><familyname>Taylor</familyname><customfield xsi:type="BooleanTypeCustomField"><definitionid>Bill With Parent</definitionid><value>false</value></customfield><customfield xsi:type="StringTypeCustomField"><definitionid>Preferred Delivery Method</definitionid><value>EMAIL</value></customfield><showas>Taylor Dorothy CON18</showas><openbalance><amount>0</amount></openbalance></website></customer><customer><id iddomain="QBO">13</id><synctoken>1</synctoken><metadata><createtime>2013-07-10T08:35:29-07:00</createtime><lastupdatedtime>2013-08-06T00:23:25-07:00</lastupdatedtime></metadata><name>Williams Linda CON19</name><address><line1>345 Sugar Blvd.</line1><city>San Francisco</city><country>USA</country><countrysubdivisioncode>CA</countrysubdivisioncode><postalcode>99999</postalcode><geocode>LAT=37.8887062,LNG=-122.4587342</geocode><tag>Billing</tag></address><phone><devicetype>Primary</devicetype><freeformnumber>(660) 958-6460</freeformnumber></phone><phone><devicetype>Mobile</devicetype><freeformnumber>(534) 043-4859</freeformnumber></phone><website><email><address>[email protected]</address></email><givenname>Linda</givenname><familyname>Williams</familyname><customfield xsi:type="BooleanTypeCustomField"><definitionid>Bill With Parent</definitionid><value>false</value></customfield><customfield xsi:type="StringTypeCustomField"><definitionid>Preferred Delivery Method</definitionid><value>EMAIL</value></customfield><showas>Williams Linda CON19</showas><openbalance><amount>391</amount></openbalance></website></customer><customer><id iddomain="QBO">26</id><synctoken>0</synctoken><metadata><createtime>2013-08-03T07:01:20-07:00</createtime><lastupdatedtime>2013-08-03T07:01:20-07:00</lastupdatedtime></metadata><name>Williams Linda CON3</name><address><line1>345 Sugar Blvd.</line1><city>San Francisco</city><country>USA</country><countrysubdivisioncode>CA</countrysubdivisioncode><postalcode>99999</postalcode><geocode>LAT=37.8887062,LNG=-122.4587342</geocode><tag>Billing</tag></address><phone><devicetype>Primary</devicetype><freeformnumber>(660) 958-6460</freeformnumber></phone><phone><devicetype>Mobile</devicetype><freeformnumber>(534) 043-4859</freeformnumber></phone><website><email><address>[email protected]</address></email><givenname>Linda</givenname><familyname>Williams</familyname><customfield xsi:type="BooleanTypeCustomField"><definitionid>Bill With Parent</definitionid><value>false</value></customfield><customfield xsi:type="StringTypeCustomField"><definitionid>Preferred Delivery Method</definitionid><value>EMAIL</value></customfield><showas>Williams Linda CON3</showas><openbalance><amount>0</amount></openbalance></website></customer><customer><id iddomain="QBO">18</id><synctoken>1</synctoken><metadata><createtime>2013-07-10T08:35:41-07:00</createtime><lastupdatedtime>2013-08-03T06:56:49-07:00</lastupdatedtime></metadata><name>Wilson Susan CON20</name><address><line1>999 Baker Way</line1><city>Sunnyvale</city><country>USA</country><countrysubdivisioncode>CA</countrysubdivisioncode><postalcode>99999</postalcode><geocode>LAT=37.3118253,LNG=-122.0549614</geocode><tag>Billing</tag></address><phone><devicetype>Primary</devicetype><freeformnumber>(422) 519-5069</freeformnumber></phone><phone><devicetype>Mobile</devicetype><freeformnumber>(333) 629-8844</freeformnumber></phone><website><email><address>[email protected]</address></email><givenname>Susan</givenname><familyname>Wilson</familyname><customfield xsi:type="BooleanTypeCustomField"><definitionid>Bill With Parent</definitionid><value>false</value></customfield><customfield xsi:type="StringTypeCustomField"><definitionid>Preferred Delivery Method</definitionid><value>EMAIL</value></customfield><showas>Wilson Susan CON20</showas><openbalance><amount>0</amount></openbalance></website></customer></qbo:cdmcollections><qbo:count>16</qbo:count><qbo:currentpage>1</qbo:currentpage></qbo:searchresults>

Upvotes: 0

Views: 464

Answers (1)

Keith Palmer Jr.
Keith Palmer Jr.

Reputation: 27962

According to your example code, you're querying for CUSTOMERS, not INVOICES. So the rest of my response will assume you're talking about customers.

According to Intuit's documentation about the Customer endpoint, customers do not support sorting by the LastUpdatedTime field.

You'll have to use one of the supported sorting fields if you want to sort the result set.

Upvotes: 4

Related Questions