Rob
04/03/2025, 12:16 PMCeligo AI
04/03/2025, 12:16 PMAI generated answer (using internal Slack threads):To export a saved search to a CSV file via script, you can use the
task
module in SuiteScript. Here is a sample code snippet that demonstrates how to do this:
javascript
define(['N/task','N/record','N/search'],
function(task, record, search) {
function execute(context) {
const searchMap = {3597 : 'file1'} //searchId : filename
Object.keys(searchMap).map(function(each) {
let searchTask = task.create({
taskType: task.TaskType.SEARCH
});
searchTask.savedSearchId = each;
let path = `ExportFolder/${searchMap[each]}.csv`;
searchTask.filePath = path;
let searchTaskId = searchTask.submit();
log.debug("searchTaskId",searchTaskId)
})
}
return {
execute : execute
};
}
);
In this code, searchMap
is a dictionary where the key is the ID of the saved search and the value is the filename for the CSV file. The task.create
function creates a new search task, and the task.TaskType.SEARCH
specifies that this is a search task. The savedSearchId
property is set to the ID of the saved search, and the filePath
property is set to the path where the CSV file will be saved. The searchTask.submit
function submits the search task and returns the ID of the task.
Please note that you need to replace 3597
with the ID of your saved search and 'file1'
with your desired filename. Also, replace ExportFolder
with the actual path of the folder in the file cabinet where you want to save the CSV file.
******
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
04/03/2025, 12:17 PMSlack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.864699721
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.861216962
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.860086739
Celigo AI
04/03/2025, 12:17 PM