在运行时生成GUID,而无需在NetSuite中使用表单 [英] Generate GUID at runtime without using form in NetSuite

查看:159
本文介绍了在运行时生成GUID,而无需在NetSuite中使用表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

我正在尝试在NetSuite中准备一个计划脚本,该脚本将从文件柜中选择一个特定目录并将其部署在SFTP服务器上.我正在使用2.0模块,这是我的代码-

I'm trying to prepare a scheduled script in NetSuite which will pick a particular directory from file cabinet and deploy it on SFTP server. I'm using 2.0 module and here is my code -

require(["N/sftp",'N/record','N/file'], function(sftp,record,file) {

    function onRequest() {
        var myPwdGuid = "13139ac567b14f74bdaXXXXXXX";
        var myHostKey = "AAAAB3NzaC1ycXXXXX";

        var connection = sftp.createConnection({
            username: 'Your user name',
            passwordGuid: myPwdGuid,
            url: 'Your host name',
            directory: '/directory to upload files/',
            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'
        });
    }

    onRequest();
    return {
        onRequest: onRequest
    };
});

现在的问题是,当我尝试运行这些代码行时,出现错误消息"AN_ERROR_OCCURRED_WHILE_DECRYPT_PASSWORDGUID". 到目前为止,通过研究我发现的是GUID只能由具有凭据字段的SuitLet表单生成,这又需要GET和POST方法.但是我不想创建一个套件并手动调用它来生成GUID.我要做的就是-运行计划的脚本,该脚本将建立与SFTP的连接.在文件柜中选择一个目录,然后将其上传到SFTP.

Now the issue is when i try to run these lines of code i get an error saying "AN_ERROR_OCCURRED_WHILE_DECRYPT_PASSWORDGUID". What i've found so far through my research is GUID can only be generated by SuitLet form having credential field which will again require GET and POST method. However i Dont want to create a suitelet and invoke it manually in order to generate GUID. All i want to to do is - Run a scheduled script which will Establish connection to SFTP. Pick a directory in file cabinet and upload it on SFTP.

任何帮助将不胜感激!预先感谢!

Any help would be greatly appreciated! Thanks in advance!

推荐答案

NetSuite不支持直接对SFTP密码进行硬编码的功能. NetSuite使用密码标记来防止脚本访问用户凭据.因此,只有经过身份验证的用户才能存储密码,脚本只能通过标识符(GUID/令牌)访问密码.

The ability to directly hard-code an SFTP password is not supported in NetSuite. NetSuite uses password tokenization in order to prevent scripts from having access to user credentials. For this reason, only an authenticated user may store a password, and a script may only access it via an identifier (GUID/Token).

这篇关于在运行时生成GUID,而无需在NetSuite中使用表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆