SuiteScript2.0 从用户事件调用 Suitelet 不工作
SuiteScript2.0 calling a Suitelet From User Event Not Working
我想要发生什么
我希望能够从传入记录 ID 的用户事件中调用 Suitelet。
目前发生的事情
抛出 "INSUFFICIENT_PERMISSION" 错误或未抛出错误但未调用 suitelet。
详情
大家好,我正在尝试从用户事件调用 suitelet。我们有一条记录是用一些数据创建的,在我想创建客户和销售订单的用户事件中创建该记录时。我还需要触发这些记录的用户事件。我知道一个用户事件不能触发另一个用户事件,所以我写了一个 suitelet 来调用它来进行处理。我正在尝试使用以下代码调用 suitelet。
var scheme = 'https://';
var host = url.resolveDomain({
hostType: url.HostType.APPLICATION
});
var suitletURL = url.resolveScript({
scriptId : 'customscript_pws_sl_data',
deploymentId : 'customdeploy_pws_sl_data'
});
var parameters = {
dataid : scriptContext.newRecord.id,
};
log.debug("URL", scheme + host + suitletURL);
var response = https.post({
url : scheme + host + suitletURL + "&dataid=" + scriptContext.newRecord.id,
body : parameters
});
使用此代码,不会抛出任何错误,但也不会触发 Suitelet。我知道这一点,因为一旦我的 suitelet 触发,我就会记录 "Running"
log.debug("Running");
var user = runtime.getCurrentUser();
var script = runtime.getCurrentScript();
// Get parameters
var params = context.request.parameters;
log.debug("Context", JSON.stringify(context.request));
log.debug("Params", JSON.stringify(params));
现在我正在记录用户事件正在使用的 URL,如果我将其复制并粘贴到浏览器中,suitelet 就会运行。所以我知道 URL 是正确的。
我尝试了什么
我试过添加
returnExternalUrl: true
https 调用的参数。使用此 DOES 调用 Suitelet 但是我可能会出现错误
"type":"error.SuiteScriptError","name":"INSUFFICIENT_PERMISSION","message":"Permission Violation: You need the 'Lists -> Items' permission to access this page. Please contact your account administrator.","stack":["createError(N/error)","getOrderLines(/SuiteScripts/PWS Additional Modules/Additional Modules/Ecommerce Data/pws_lib_ecommerce.js:972)","processData(/SuiteScripts/PWS Additional Modules/Additional Modules/Ecommerce Data/pws_lib_ecommerce.js:109)","onRequest(/SuiteScripts/PWS Additional Modules/Additional Modules/Ecommerce Data/pws_sl_ecommdata.js:40)"],"cause":{"type":"internal error","code":"INSUFFICIENT_PERMISSION","details":"Permission Violation: You need the 'Lists -> Items' permission to access this page. Please contact your account administrator.","userEvent":null,"stackTrace":["createError(N/error)","getOrderLines(/SuiteScripts/PWS Additional Modules/Additional Modules/Ecommerce Data/pws_lib_ecommerce.js:972)","processData(/SuiteScripts/PWS Additional Modules/Additional Modules/Ecommerce Data/pws_lib_ecommerce.js:109)","onRequest(/SuiteScripts/PWS Additional Modules/Additional Modules/Ecommerce Data/pws_sl_ecommdata.js:40)"],"notifyOff":false},"id":"","notifyOff":false,"userFacing":false}
套件部署设置为 "Available Without Login : true" 和 "All Roles : true"
更新
I am getting You must login before accessing this page.
我已登录并从 UserEvent 调用它
在管理员模式下将用户事件和 Suitelet 都设置为 运行 并使用 "returnExternalUrl: true" 设置解决了这个问题:)
var suitletURL = url.resolveScript({
scriptId : 'customscript_pws_sl_data',
deploymentId : 'customdeploy_pws_sl_data',
returnExternalUrl : true
});
我想要发生什么
我希望能够从传入记录 ID 的用户事件中调用 Suitelet。
目前发生的事情
抛出 "INSUFFICIENT_PERMISSION" 错误或未抛出错误但未调用 suitelet。
详情
大家好,我正在尝试从用户事件调用 suitelet。我们有一条记录是用一些数据创建的,在我想创建客户和销售订单的用户事件中创建该记录时。我还需要触发这些记录的用户事件。我知道一个用户事件不能触发另一个用户事件,所以我写了一个 suitelet 来调用它来进行处理。我正在尝试使用以下代码调用 suitelet。
var scheme = 'https://';
var host = url.resolveDomain({
hostType: url.HostType.APPLICATION
});
var suitletURL = url.resolveScript({
scriptId : 'customscript_pws_sl_data',
deploymentId : 'customdeploy_pws_sl_data'
});
var parameters = {
dataid : scriptContext.newRecord.id,
};
log.debug("URL", scheme + host + suitletURL);
var response = https.post({
url : scheme + host + suitletURL + "&dataid=" + scriptContext.newRecord.id,
body : parameters
});
使用此代码,不会抛出任何错误,但也不会触发 Suitelet。我知道这一点,因为一旦我的 suitelet 触发,我就会记录 "Running"
log.debug("Running");
var user = runtime.getCurrentUser();
var script = runtime.getCurrentScript();
// Get parameters
var params = context.request.parameters;
log.debug("Context", JSON.stringify(context.request));
log.debug("Params", JSON.stringify(params));
现在我正在记录用户事件正在使用的 URL,如果我将其复制并粘贴到浏览器中,suitelet 就会运行。所以我知道 URL 是正确的。
我尝试了什么
我试过添加
returnExternalUrl: true
https 调用的参数。使用此 DOES 调用 Suitelet 但是我可能会出现错误
"type":"error.SuiteScriptError","name":"INSUFFICIENT_PERMISSION","message":"Permission Violation: You need the 'Lists -> Items' permission to access this page. Please contact your account administrator.","stack":["createError(N/error)","getOrderLines(/SuiteScripts/PWS Additional Modules/Additional Modules/Ecommerce Data/pws_lib_ecommerce.js:972)","processData(/SuiteScripts/PWS Additional Modules/Additional Modules/Ecommerce Data/pws_lib_ecommerce.js:109)","onRequest(/SuiteScripts/PWS Additional Modules/Additional Modules/Ecommerce Data/pws_sl_ecommdata.js:40)"],"cause":{"type":"internal error","code":"INSUFFICIENT_PERMISSION","details":"Permission Violation: You need the 'Lists -> Items' permission to access this page. Please contact your account administrator.","userEvent":null,"stackTrace":["createError(N/error)","getOrderLines(/SuiteScripts/PWS Additional Modules/Additional Modules/Ecommerce Data/pws_lib_ecommerce.js:972)","processData(/SuiteScripts/PWS Additional Modules/Additional Modules/Ecommerce Data/pws_lib_ecommerce.js:109)","onRequest(/SuiteScripts/PWS Additional Modules/Additional Modules/Ecommerce Data/pws_sl_ecommdata.js:40)"],"notifyOff":false},"id":"","notifyOff":false,"userFacing":false}
套件部署设置为 "Available Without Login : true" 和 "All Roles : true"
更新
I am getting You must login before accessing this page.
我已登录并从 UserEvent 调用它
在管理员模式下将用户事件和 Suitelet 都设置为 运行 并使用 "returnExternalUrl: true" 设置解决了这个问题:)
var suitletURL = url.resolveScript({
scriptId : 'customscript_pws_sl_data',
deploymentId : 'customdeploy_pws_sl_data',
returnExternalUrl : true
});