simon rodrigs
simon rodrigs

Reputation: 21

Can we use NetSuite suitescript to read data from a SFTP folder?

I have a requirement to export payment files from NetSuite to a secure ftp folder and read the status of the payments back into NetSuite from the secure ftp folder.

I do not want to maintain any code in an external system. Does anyone know, How do I achieve this using Suite Script in Netsuite ?

Thanks a lot !

Upvotes: 2

Views: 3309

Answers (3)

Adolfo Garza
Adolfo Garza

Reputation: 3029

I made a tool and a video tutorial on how to use the new SFTP module of 2016.2 Suitescript API. It has everything you need to kickstart your script project like getting a passwordGUID and a hostkey of the sftp server.

Connecting to SFTP

Check the code here

Upvotes: 5

scheppsr77
scheppsr77

Reputation: 577

I know this response is a little late however NetSuite just replaced SFTP.

If you have access to NetSuite SuiteAnswers, check out the link below. https://netsuite.custhelp.com/app/answers/detail/a_id/51361

/**
*@NApiVersion 2.x
*/
require(['N/sftp', 'N/file'],
function(sftp, file) {
    var myPwdGuid = "B34672495064525E5D65032D63B52301";
    var myHostKey = "AAA1234567890Q=";

    var connection = sftp.createConnection({
        username: 'myuser',
        passwordGuid: myPwdGuid,
        url: 'host.somewhere.com',
        directory: 'myuser/wheres/my/file',
        hostKey: myHostKey
    });

    var myFileToUpload = file.create({
        name: 'originalname.js',
        fileType: file.fileType.PLAINTEXT,
        contents: 'I am a test file. Hear me roar.'
    });

    connection.upload({
        directory: 'relative/path/to/remote/dir',
        filename: 'newFileNameOnServer.js',
        file: myFileToUpload,
        replaceExisting: true
    });

    var downloadedFile = connection.download({
        directory: 'relative/path/to/file',
        filename: 'downloadMe.js'
    });
});

Upvotes: 3

vVinceth
vVinceth

Reputation: 915

Using SuiteScript alone is impossible. You need to create an external app that will read the file from NetSuite via web service/suitetalk and upload it to the FTP or vice versa.

Upvotes: 2

Related Questions