I need to retrieve a list of all the items in a sa...
# suitescript
j
I need to retrieve a list of all the items in a sales order with the price, quantity, etc, so that I can use the data to assemble a ZPL print string for sales receipts. I will be using the internalid of the SO to call the SuiteLet. I have spent quite a bit of time on this, and so far I have not got anything to work. The ZPL string is not a problem, I just can't seem to retrieve the SO object including all of the Items. I mostly write C#, and it is no problem getting the data using SuiteTalk; but the javascript API does not seem to return the entire Sales Order.
b
You have 2 general choices to retrieve data, the N/record module and the N/search module
which have you chosen to use
j
I have been using N/search I am new to SuiteScript though, and may be doing it all wrong.
b
what does your search code look like
j
Here is the basic search I started with: [code] function findOrder(id) { return s.create({ type: s.Type.SALES_ORDER, filters: [ ["internalid", s.Operator.IS, [id]], "and", ["mainline", s.Operator.IS, ["T"]] ] , columns: ["item", "quantity", "amount"] }).run().getRange({start: 0, end: 1}); } [/code]
b
you probably want to create the search in the ui first
the equivalent search in the ui would make it easier to see that your mainline is true filter is exluding the item lines
j
I have tried turning off mainline, but still can't seem to drill down to the Item list.
b
in general, mainline false on a sales order will have rows that represent tax items, discount items, shipping items, and regular items
each search result represents one row from the search (the same rows as the ui search
when you use getRange, you are choosing how may rows to get
that range should be much larger if you expect sales orders with multiple lines
j
Thank you. I am doing more testing...
t
If you use the record module, request the sales order and turn it toJSON() you will have access to everything you need
j
@Timothy Thank you. An object is what I was hoping to get, but could not figure out how. I will investigate.
t
Not sure how much time you’ve spent with SS2.0 but if you wrap your module with require instead of define, while your testing, you can paste it in the browser console and view the object and if you add &xml=T to the end of any records url you can view the raw xml as well.
j
I am new to SS. Thanks!
I am now able to get the needed data using N/record. THANK YOU for the help!
s
if you mostly write C#, I recommend considering NFT as it surfaces NS data similarly to how you might with C#/.NET https://www.npmjs.com/package/netsuite-fasttrack-toolkit-ss2
j
@stalbert Thanks! I will check into that.