ディスカッション

NetSuiteの保存検索やレポートをマスターするための究極のガイドである分析センターを使用して、データの力を最大限に活用しましょう。複雑さを単純化し、組織の真の可能性を解き放ちます。今すぐ分析センターに参加して、新たな高みを目指しましょう!
New AI Community Guidelines. Please review and follow them to ensure AI use stays safe, accurate, and compliant.
Update: Narrative Insights has been restored and is now available.

Narrative Insights is Temporarily Unavailable due to an Infrastructure Issue. Learn how This Impacts Your Account and What to Expect While the Feature is Disabled.

SuiteScript 1.0 vs 2.0:クライアントスクリプトからRESTletを呼び出す

適用

製品: NetSuite 2019.2



シナリオ

この記事では、クライアントスクリプトによりRESTletを呼び出す方法について説明します。クライアントスクリプトは、バックエンドロジック処理に使用されるデータをRESTletに渡します。 RESTletはそのジョブを完了した後、結果のオブジェクトを表示目的でクライアントスクリプトに渡します。



解決策

以下のサンプルコードスニペットは、ユーザーがSuiteScript 2.0バージョンへのアップグレードをしたい場合に、既存のSuiteScript 1.0コードを理解して解釈するのに役立ちます。

  • RESTlet Script 1.0 - Create and Deploy
 function postRESTlet(dataIn) { 
 
//JSON文字列をJSONオブジェクトへ変換 
var dataIn = JSON.parse(dataIn); 
nlapiLogExecution('DEBUG', 'dataIn.salesRep', dataIn.salesRep); 
 
//従業員レコードをロード 
var salesRep = nlapiLoadRecord('employee', dataIn.salesRep); 
return JSON.stringify(salesRep); 
} 
クライアントスクリプト1.0 - スクリプトを作成して、注文書へデプロイ 
 function clientFieldChanged(type, name, linenum){ 
if (name == 'salesrep') { 
nlapiLogExecution('DEBUG', 'Field Change In'); 
var salesRep = nlapiGetFieldValue('salesrep'); 
var postData = {"salesRep": salesRep}; 
 
//JavaScript値をJavaScript Object Notation (JSON)文字列に変換 
postData = JSON.stringify(postData); 
nlapiLogExecution('DEBUG', postData, postData); 
 
// 動的にRESTlet URLを生成 
var restUrl = nlapiResolveURL('RESTLET', 'customscript257', 'customdeploy1'); 
nlapiLogExecution('DEBUG', 'restUrl', restUrl); 
 
// リクエストヘッダーを生成 
var headers = new Array(); 
headers['Content-type'] = 'application/json'; 
 
// HTTP POST callを実行 
var salesRepRec = nlapiRequestURL(restUrl

ようこそ!

サインイン

完全な詳細を表示するには、サインインしてください。

登録

アカウントがありませんか?ここをクリックして始めましょう!

リーダーボード

コミュニティの達人

第2四半期 (4月~6月 2026)

今週のリーダー

今月のリーダー

歴代リーダー