Hello! I am fairly new to both Netsuite, SuiteQL a...
# suiteql
a
Hello! I am fairly new to both Netsuite, SuiteQL and the REST api, so please bear with me. I have a pretty simple query that is working fine like this:
SELECT * FROM transaction WHERE (entity = xxxxx) AND (type = 'SalesOrd')
But adding the
ORDER BY
clause:
SELECT * FROM transaction WHERE (entity = xxxxx) AND (type = 'SalesOrd') ORDER BY trandate
Causes the REST API to return an empty result set. It seems counter-intuitive that simply adding an
ORDER
clause would change the number of records that get returned. In other cases, attempting to sort by date fields results in a
500 - Internal Server Error
- perhaps related to the issue @Peter Church reported above?
m
I wonder if you have some transactions where the
trandate
is corrupted or something. I would be curious if the following queries work:
SELECT trandate FROM transaction WHERE (entity = xxxxx) AND (type = 'SalesOrd')
SELECT trandate FROM transaction WHERE (entity = xxxxx) AND (type = 'SalesOrd') ORDER BY trandate
a
Thanks for the response! The first query works, the second does not...
Copy code
{
  "links": [
    {
      "rel": "self",
      "href": "<https://xxxxxxx-sb3.suitetalk.api.netsuite.com/services/rest/query/v1/suiteql?limit=50>"
    }
  ],
  "count": 0,
  "hasMore": false,
  "items": [],
  "offset": 0,
  "totalResults": 6
}
I tried with a different customer to be sure, and got the same results
m
You might just have to specify
asc
or
desc
(ascending or descending) at the end
so
SELECT * FROM transaction WHERE (entity = xxxxx) AND (type = 'SalesOrd') ORDER BY trandate DESC
or ``SELECT * FROM transaction WHERE (entity = xxxxx) AND (type = 'SalesOrd') ORDER BY trandate ASC`
that seemed to solve the issue for me at least
p
@Marc Reicher that solves it by the looks👌
a
Wow... how could I have missed that!
Thank you! 🙏
m
Hah bad error messaging for sure.
Also suiteql should default to ASC or DESC but it doesn’t