ディスカッション
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.
NetSuite の始め方 | N/record: record.load(オプション) メソッド
以前の記事では、NetSuite の始め方| SuiteScript 2.xモジュールについてにて、SuiteScript モジュール、NetSuite の始め方 | N/recordモジュールの概要にて、N/record モジュールについて解説しました。これはレコードを操作するために使用されます。今回は、N/record のメンバーの一つであるrecord.load(オプション) メソッドについて詳しく見ていきます。
SuiteScript 2.x における record.load(options) メソッドは、既存のレコードをメモリ上に読み込み、スクリプトから参照・更新・処理できるようにするためのものです。
record.load()は、内部 IDを指定してレコードを取得します。
レコードが読み込まれると、次の操作を行うことができます。:
- フィールド値の取得
- フィールドの更新
- 明細ライン行(サブリスト)の追加・削除
- レコードの保存
- バリデーションの実行
- ビジネスロジックのトリガー
シンタックス
var recordObj = record.load({
type: record.Type.SALES_ORDER, // or a string like 'salesorder'
id: 1234, // レコードのInternal ID
isDynamic: false // オプション:ダイナミックモードでのレコード読み込み
});
パラメータ
- type (string or record.Type enum):読み込みたいレコードの種類を指定します(例: record.Type.SALES_ORDER, 'customer', 等).
- id (number):読み込みたいレコードのInternal ID
- isDynamic (boolean, optional):レコードをダイナミックモード(true)で読み込むか、標準モード(false)で読み込むかを指定します。
- ダイナミックモードでは、NetSuite の UI 操作に近い方法で、レコードのフィールドやサブリストの値を更新できます。
戻り値
フィールド値やサブリストにアクセス・更新したり、レコード操作を実行したりするために使用できるRecord オブジェクトを返します。
サンプル:スケジュールスクリプトで販売オーダー(Sales Order)の読み込み
以下は、スケジュールスクリプトでrecord.load()を使用する基本的なサンプルです。
/**
* @NApiVersion 2 .x
* @NScriptType ScheduledScript
*/
define(['N/record', 'N/log'], function(record, log) {
function execute(context) {
try {
// 例:Internal ID 1234の販売オーダーを読み込む
var salesOrder = record.load({
type: record.Type.SALES_ORDER,
id: 1234,
isDynamic: false // UI 操作に近い即時動作が必要な場合は true を設定します
});
// 例:販売オーダーに紐づく顧客を取得
var customerId = salesOrder.getValue({ fieldId: 'entity' }); Richard James Uri - SuiteCloud | WMS Tech | SuiteCommerce Advanced
----
- NetSuite Admin Corner | New to NetSuite
- Explore the NSC Webinars Category
- Join our poll and share your ideas! We want to know what you think. Don't forget to comment and make your voice heard!
- Expand your NetSuite knowledge by joining this month's Ask A Guru Live: PROCURE TO PAY. RSVP on this event now!
タグ付けされた:
0
