i have a saved search and i need to save the resul...
# suitescript
v
i have a saved search and i need to save the results of a saved search into the contents of the file. how to achieve this?
n
What file? CSV? PLAINTEXT? something else obscure?
s
Copy code
const savedSearchId = 669;

    // Create the search task
    let myTask = task.create({
        taskType: task.TaskType.SEARCH
    });
    myTask.savedSearchId = savedSearchId;

    // Specify the ID of the file that search results will be exported into
    myTask.fileId = 448;

    // Submit the search task
    let myTaskId = myTask.submit();

    // Retrieve the status of the search task
    let taskStatus = task.checkStatus({
        taskId: myTaskId
    });

    // Optionally, add logic that executes when the task is complete
    if (taskStatus.status === task.TaskStatus.COMPLETE) {

    }
v
CSV
i need to add the results into contents in the file.create.
n
I'd recommend you use papaparse library to create your file content.
Convert your search results to JSON capturing the detail you need and then get papaparse to create your file contents from the JSON.
v
Any code sample sir?
n
plenty examples in the papaparse documentation.