mescalante
05/20/2025, 7:30 PMCeligo AI
05/20/2025, 7:31 PMAI generated answer (using internal Slack threads):Based on the conversations, it seems that you can export a Saved Search to an FTP folder using SuiteScript by following these steps: 1. Process the Saved Search and write the results to a CSV file using a script. 2. Use the
N/sftp
module to upload the CSV file to an SFTP server.
Here is a sample code snippet that demonstrates this process:
javascript
const executeExportIntegration = (record) => {
let searchId = record.getValue('custrecord_mvc_saved_search');
let fileName = record.getValue('custrecord_mvc_file_name');
let directory = record.getValue('custrecord_mvc_ftp_folder');
if(fileName === '') {
fileName = searchId;
}
const searchToExport = search.load({id: searchId}).run().getRange({
start: 0,
end: 1000
});
let csvData = _convertSearchToCsv(searchToExport);
let fileObj = file.create({
name: fileName + '.csv',
fileType: file.Type.PLAINTEXT,
contents: csvData
});
let connection = _connectionSFTP(record);
let objConnection = connection.list({
path: directory
});
log.debug('Current Folder', objConnection);
connection.upload({
file: fileObj,
filename: 'af.txt',
replaceExisting: true
});
}
Please note that this code assumes that you have functions _convertSearchToCsv
and _connectionSFTP
defined elsewhere in your script. The _convertSearchToCsv
function should convert the Saved Search results into CSV format, and the _connectionSFTP
function should establish an SFTP connection.
******
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
05/20/2025, 7:31 PMSlack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.856191337
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.85195291
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.837210119
Celigo AI
05/20/2025, 7:31 PM