Hello,
I am trying to do my first 2.0 script, and it is just downloading a file from an FTP. I made it a scheduled search and when I try to run it at the debugger I get the following:
Cannot find function createConnection in object [object Object].
Code:
/**
* @NApiVersion 2.x
* @NScriptType ScheduledScript
* @NModuleScope SameAccount
*/
define([‘N/file’,’N/sftp’],
/**
* @param {file} file
* @param {sftp} sftp
*/
function(sftp,file) {
function execute(context) {
var myPwdGuid = “XXXXXXXXXX”;
//var myHostKey = “XXXXXXXXXXXXXX”;
var connection = sftp.createConnection({
username: ‘usernameXX’,
passwordGuid: myPwdGuid, // references var myPwdGuid
url: ‘sft.testnet’,
directory: ‘/Outbound/’,
hostKey: myHostKey
});
// download the file from the remote server
var downloadedFile = connection.download({
directory: ‘/Outbound/’,
filename: ‘test.csv’
});
}
return {
execute: execute
};
});
This is a cached copy. Click here to see the original post.