ディスカッション
NetSuiteの保存検索やレポートをマスターするための究極のガイドである分析センターを使用して、データの力を最大限に活用しましょう。複雑さを単純化し、組織の真の可能性を解き放ちます。今すぐ分析センターに参加して、新たな高みを目指しましょう!
注文書からシリアル/ロット番号付きアイテムを含む配送を作成する
適用
製品: NetSuite 2020.2
シナリオ
注文書の承認後に配送レコードを自動的に作成するサンプル・ユーザー・イベント・スクリプトです。
注文書には、ロット/シリアル番号を使用する在庫詳細サブレコードがあるアイテムが含まれています。
UIと同様に、シリアル/ロット番号は在庫詳細サブレコードに既に入力されています。シリアル/ロット番号の値は、注文書と同じです。
解決策
下記コードを使用するユーザーイベントスクリプトを作成します。
/** * NApiVersion 2.x * NScriptType UserEventScript * NModuleScope SameAccount */ define(['N/record'], /** * @param {record} * record */ function (record) { function afterSubmit(scriptContext) { var eventType = scriptContext.type; var newRecId = scriptContext.newRecord.id; var newRecStatus = scriptContext.newRecord.getValue({ fieldId: 'status' }); if (newRecStatus == 'Pending Approval') { //check if Pending Approval as script would throw an error when creating a new SO log.debug({ title: 'record ID', details: newRecId }); var recordObj = record.transform({ fromType: record.Type.SALES_ORDER, fromId: newRecId, toType: record.Type.ITEM_FULFILLMENT }); var objSubRecord = recordObj.getSublistSubrecord({ sublistId: 'item', fieldId: 'inventorydetail', line: 0 }); objSubRecord.setSublistValue({ sublistId: 'inventoryassignment', fieldId: 'quantity', value: 1, line: 0 }); objSubRecord.setSublistValue({ sublistId: 'inventoryassignment', fieldId: 'issueinventorynumber
タグ付けされた:
0