Reputation: 1239
I'm working on a script which required to find a particular product SKU within a Sales Order.
Order is placed through webservice API and every time an order is placed, I need to search for a particular product.
I did look at the Suitescript 2.0 API documentation and its seems there are a two options for me to investigate: 1 - Line item, 2 - Sublist
I'm wondering if anyone can give me a hint on how to achieve this on suitescript 2.0
Upvotes: 0
Views: 954
Reputation: 3039
Here's how to find a line in SS2.0.
// Finding a specific line item in SuiteScript 2.0...
require(["N/record"], function (r) {
var rec = r.load({
"type": r.Type.SALES_ORDER,
"id": 123
});
// Find the line that contains item 777
var index = rec.findSublistLineWithValue({"sublistId": "item", "fieldId": "item", "value": 777});
// find returns -1 if the item isn't found
if (index > -1) {
// we found it on line "index"
} else {
// item 777 is not in the list
}
});
Upvotes: 2