Lorenzo
09/09/2024, 11:17 AMCeligo AI
09/09/2024, 11:17 AMAI generated answer (using internal Slack threads):To get a batch of sales orders using REST API, you can use the Search API in SuiteScript 2.0. You can filter the sales orders by the
createdOn
field to get sales orders created between two specific dates. Here is a basic example of how you can do this:
javascript
var search = require('N/search');
function execute(context) {
var salesOrderSearch = search.create({
type: search.Type.SALES_ORDER,
filters: [
['datecreated', 'within', '1/1/2021', '12/31/2021']
],
columns: ['tranid', 'entity', 'total']
});
var pagedData = salesOrderSearch.runPaged({pageSize: 1000});
pagedData.pageRanges.forEach(function(pageRange) {
var page = pagedData.fetch({index: pageRange.index});
page.data.forEach(function(result) {
log.debug({
title: 'Sales Order',
details: JSON.stringify(result)
});
});
});
}
This script will return all sales orders created between 1/1/2021 and 12/31/2021. You can adjust the dates and the fields returned (tranid
, entity
, total
) as needed.
******
Disclaimer:
This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes.
******Celigo AI
09/09/2024, 11:17 AMSlack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.819929719
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.817258
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.808306754
Celigo AI
09/09/2024, 11:17 AM