ディスカッション
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.
新規ライン住所がSuiteScriptの既存の住所サブレコード行を更新する
適用
製品: NetSuite 2022.1
シナリオ
新しい住所を「住所」サブレコードに追加すると、新しいラインの住所によって既存の直前の行も更新されます。
この動作は、動的モードでレコードをロードするときに発生する可能性があります。レコードはレコードの本文フィールドの自動ソーシング、計算および検証に事実上従うため、このモードではデータは機密です。
ノート: 同じ機能の下にレコードをロードして保存するのがベスト・プラクティスです。コードの読みやすさ、デバッグ、およびトレースを向上させます。
解決策
以下は、新しいライン・アイテムを作成し、目的のライン・アイテムのみを更新するサンプルSuiteScript 2.0スクリプトです。
//Your code here...
try{
//Using N/record Module record.load(options)
var recordObj = record.load({
type: record.Type.SALES_ORDER, //The record type
id: 123, //The internal ID of the existing record
isDynamic: false //If set to false, the record is loaded in standard mode
});
//Select new address line. Simulates clicking "Add" button
recordObj.selectNewLine('addressbook');
var targetSubrecord = recordObj.getCurrentSublistSubrecord({
sublistId: 'addressbook',
fieldId: 'addressbookaddress'
});
//Set address fields. Logging added to show before and after.
log.debug('Record Object -before', targetSubrecord);
targetSubrecord.setValue('country', sourceAddressCountry);
targetSubrecord.setValue('attention', sourceAddressAttention);
targetSubrecord.setValue('addressee', sourceAddressAddressee);
targetSubrecord.setValue('addrphone', sourceAddressAddrphone);
targetSubrecord.setValue('addr1', sourceAddress);
0