ディスカッション
NetSuiteの保存検索やレポートをマスターするための究極のガイドである分析センターを使用して、データの力を最大限に活用しましょう。複雑さを単純化し、組織の真の可能性を解き放ちます。今すぐ分析センターに参加して、新たな高みを目指しましょう!
New AI Community Guidelines. Please review and follow them to ensure AI use stays safe, accurate, and compliant.
Keep an eye out for upcoming NetSuite events, including meetups, workshops, and webinars. These sessions are a great way to connect with peers, learn from experts, and stay current on the latest NetSuite updates and best practices. Registration links are provided in each event.
SuiteScript2.0ユーザーイベントスクリプトボタンのクリック時にRESTletを実行する方法
適用
製品: NetSuite 2021.1
シナリオ
異なるスクリプトからRESTletを呼び出し、管理者として実行するには、サーバー側スクリプトから呼び出しを行う必要があります。これにより、ロールを含むユーザー資格情報を指定できます。
解決策
ユーザーイベントスクリプトから作成されたカスタムボタンからRESTletを呼び出して実行するには、一連のスクリプトをトリガーする必要があります。イメージは次のとおりです。クライアントスクリプトからon-click機能を呼び出すユーザーイベントスクリプトによりボタンを作成します。クライアントスクリプトはSuiteletを呼び出し、SuiteletはRESTletを呼び出します。ユーザーイベントスクリプトはサーバー側でありますが、カスタムボタンの機能はクライアント側のスクリプトから取得されます。そのため、RESTletの呼び出しがサーバー側のスクリプトから行われるように、追加のSuiteletが必要です。
サンプルコードスニペットは次のとおりです。
使用するもジュル
- N/url
- N/https
- N/http
1. Suitelet (サンプルスクリプトの内部ID: 203, デプロイメントID: 1)
function onRequest(context) {
log.debug(context)
if(context.request.method == 'GET')
{
log.debug('Got Here')
var url = 'https://.restlets.api.netsuite.com/app/site/hosting/restlet.nl?script=203&deploy=1';
var headers ={
"Content-type": "application/json",
"Authorization": "NLAuth nlauth_email=test@netsuite.com," +
"nlauth_signature=sampleP@ssW0rd!," +
"nlauth_account=12345," +
"nlauth_role = 3"
};
var response = https.request({
method: http.Method.GET,
url: url,
headers: headers
});
log.debug(response.body);
}
}
}
2. ユーザイベントスクリプト
function beforeLoad(scriptContext) {
var resURL = url.resolveScript({
scriptId: 'customscript205',
deploymentId: 'customdeploy1'
});
log.debug(resURL)
var form = scriptContext.form;
form.addButton({
id: 'custpage_button',
label: 'Run RESTlet',
functionName: "goToSuitelet('"+resURL+"')" //
タグ付けされた:
0