Slackbot
02/16/2025, 11:32 AMCeligo AI
02/16/2025, 11:32 AMAI generated answer (using internal Slack threads):To load a saved search and loop on the transactions and push the results of the columns in an array and return it in SuiteScript 2.0, you can use the
N/search
module. Here is a sample code snippet:
javascript
var search = require('N/search');
function loadSearchAndReturnResults() {
var myArray = [];
var mySearch = search.load({
id: 'customsearch_my_saved_search' // replace with your saved search id
});
mySearch.run().each(function(result) {
var resultObj = {};
for (var i = 0; i < result.columns.length; i++) {
var column = result.columns[i];
resultObj[column.name] = result.getValue(column);
}
myArray.push(resultObj);
return true; // continue to next result
});
return myArray;
}
In this code, we first load the saved search using the search.load
method. Then we run the search and for each result, we loop over the columns and get the value of each column. We then push the result object into the array. Finally, we return the array.
Remember to replace 'customsearch_my_saved_search'
with the actual ID of your saved search.
******
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
02/16/2025, 11:32 AMSlack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.833010197
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.832493722
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.828758299
Celigo AI
02/16/2025, 11:32 AM