This topic contains 1 reply, has 0 voices, and was last updated by michoel 6 years, 5 months ago.

  • Author
    Posts
  • #17991

    adurangalvis

    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.

  • #17992

    michoel

    Originally posted by adurangalvis

    View Post

    Code:
    define([‘N/file’,’N/sftp’],
    /**
    * @param {file} file
    * @param {sftp} sftp
    */
    function(sftp,file) {

    You need to change that last line to function(file, sftp). What you are doing now is naming the sftp module “file” and the file module “sftp”

You must be logged in to reply to this topic.