Netsuite - Getting error: Fail to evaluate script: All SuiteScript API Modules are unavailable while executing your define callback
Netsuite - Getting error: Fail to evaluate script: All SuiteScript API Modules are unavailable while executing your define callback
我尝试上传以下脚本,但遇到无法评估脚本的情况:所有 SuiteScript API 模块在执行您的定义回调时不可用 - 错误。
不确定我做错了什么,因为我基本上是在遵循 api 中的示例。
注意:这是在沙盒中完成的。
/**
* @NApiVersion 2.x
* @NScriptType Suitelet
* @NModuleScope SameAccount
*/
define(['N/email'],
/**
* @param {email} email
*/
function(email){
function sendEmail() {
var senderId = 34972;
var recipientEmail = 'email@example.com';
email.send({
author: senderId,
recipients: recipientEmail,
subject: 'Test Sample Email Module',
body: 'Thisis a test',
});
}
sendEmail();
});
这不是一个正确的 suitelet,您是在定义中调用您的函数。
从 define()
编辑的函数 return 可能会调用 Netsuite 函数,但您的 sendemail 函数正在调用定义“内部”的 Netsuite API。
如果您只是想了解 SuiteScript,请将您的定义更改为要求并在控制台中调用该代码 window。
否则请查看 suitelet 文档和 return 正确的函数对象。
如果您在 2.0 中编写 Suitelet 脚本,则需要使用回调函数的 RETURN。在您的情况下,它将类似于以下内容:
return {
onRequest : sendEmail
};
我还可以问一下 - 您尝试通过 SUITELET 触发电子邮件发送有什么原因吗?假设您想通过 Suitelet "script deployment" 页面上生成的 URL 触发电子邮件,您应该考虑包括 ServerResponse 调用以在您的浏览器上写入电子邮件已成功发送。这将类似于以下内容:
context.response.write('Email now sent');
最后 - 我还看到您在 'email.send' 对象的末尾错误地使用了逗号。删除下面指出的逗号:
email.send({
author: senderId,
recipients: recipientEmail,
subject: 'Test Sample Email Module',
body: 'Thisis a test', <---- REMOVE COMMA!
});
希望对您有所帮助。
这是一个直接的答案...注释掉任何不是本机套件脚本代码的内容...您的自定义模块,类 和上传。然后在文件柜中编辑它并取消评论你的东西
我尝试上传以下脚本,但遇到无法评估脚本的情况:所有 SuiteScript API 模块在执行您的定义回调时不可用 - 错误。
不确定我做错了什么,因为我基本上是在遵循 api 中的示例。
注意:这是在沙盒中完成的。
/**
* @NApiVersion 2.x
* @NScriptType Suitelet
* @NModuleScope SameAccount
*/
define(['N/email'],
/**
* @param {email} email
*/
function(email){
function sendEmail() {
var senderId = 34972;
var recipientEmail = 'email@example.com';
email.send({
author: senderId,
recipients: recipientEmail,
subject: 'Test Sample Email Module',
body: 'Thisis a test',
});
}
sendEmail();
});
这不是一个正确的 suitelet,您是在定义中调用您的函数。
从 define()
编辑的函数 return 可能会调用 Netsuite 函数,但您的 sendemail 函数正在调用定义“内部”的 Netsuite API。
如果您只是想了解 SuiteScript,请将您的定义更改为要求并在控制台中调用该代码 window。
否则请查看 suitelet 文档和 return 正确的函数对象。
如果您在 2.0 中编写 Suitelet 脚本,则需要使用回调函数的 RETURN。在您的情况下,它将类似于以下内容:
return {
onRequest : sendEmail
};
我还可以问一下 - 您尝试通过 SUITELET 触发电子邮件发送有什么原因吗?假设您想通过 Suitelet "script deployment" 页面上生成的 URL 触发电子邮件,您应该考虑包括 ServerResponse 调用以在您的浏览器上写入电子邮件已成功发送。这将类似于以下内容:
context.response.write('Email now sent');
最后 - 我还看到您在 'email.send' 对象的末尾错误地使用了逗号。删除下面指出的逗号:
email.send({
author: senderId,
recipients: recipientEmail,
subject: 'Test Sample Email Module',
body: 'Thisis a test', <---- REMOVE COMMA!
});
希望对您有所帮助。
这是一个直接的答案...注释掉任何不是本机套件脚本代码的内容...您的自定义模块,类 和上传。然后在文件柜中编辑它并取消评论你的东西