トランザクション・レコードを操作する際には、注文書のアイテム・サブリストのフィールドを検査するのが一般的です。混乱を引き起こす可能性のある領域の1つは、列メタデータとトランザクション行に格納されている実際の値の違いです。
たとえば、注文書アイテム・サブリストのアイテム列には、アイテムなどのラベルがあります。ただし、そのラベルはトランザクション・ラインで選択されたアイテムではありません。これは、列自体に関する情報のみです。
この記事では、SuiteScriptを使用してサブリスト列に関するメタデータを読み取ってから、注文書ラインから実際のアイテム値を個別に取得する方法を示します。
SuiteScriptの例
/**
* @NApiVersion 2 .1
* @NScriptType ScheduledScript
*/
define(['N/record', 'N/log'], (record, log) => {
/**
* Main entry point for the Scheduled Script.
*
* This example loads a Sales Order and reads metadata
* about the "item" column on the "item" sublist.
*/
const execute = (context) => {
try {
// Replace this with an existing Sales Order internal ID in your account.
const SALES_ORDER_ID = 12345;
// Internal ID of the sublist on a Sales Order.
// For transaction item lines, the sublist ID is usually "item".
const SUBLIST_ID = 'item';
// Internal ID of the column/field on the item sublist.
// This is the "Item" column.
const COLUMN_FIELD_ID = 'item';
// Load the Sales