Demand Plan Detail Sublist

The internal ID for this sublist is demandplandetail.

The Demand Plan Detail sublist appears on the Item Demand Plan record type.

The Demand Plan Detail sublist is a matrix that is similar to the Pricing sublist. This matrix stores projected quantities demanded by date. Each row in the matrix represents a specific month, week, or day, and each column in the matrix represents an expected quantity demand.

For help working with this record in the UI, see Demand Planning.

Functionally, this sublist shares many of the characteristics of List Sublists. However, scripting with the Demand Plan Detail sublist is not like scripting with most other sublists in NetSuite. You must use Matrix APIs for the Demand Plan Detail Sublist to access quantity values on a per-row, per-column basis, similar to the way that item pricing values are accessed. These APIs are a subset of the N/currentRecord Module and N/record Module APIs more commonly used for scripting with other sublists.

The format of the Demand Plan Detail sublist depends on the values set in body fields for the start date of the plan, the end date of the plan, and the time period to be used (monthly, weekly, or daily). Because of this dependence, you should work with the Item Demand Plan record and the Demand Plan Detail sublist in dynamic mode. See SuiteScript 2.x Standard and Dynamic Modes

Be aware of the following requirements:

For more details and code samples for each type of demand plan, see the following help topics:

Monthly Demand Plan

A monthly demand plan includes a row for each month within the body field start date and end date, and one quantity column for each month.

The Manual Item Demand Plan page with the monthly demand plan section highlighted.

Monthly Demand Plan Code Sample

The following sample sets quantities for the months of January and February, 2011:

          /**
 * @NApiVersion 2.1
 */

require(['N/record', 'N/log'], (record, log) => {
  const demandplan = record.create({
    type: record.Type.ITEM_DEMAND_PLAN,
    isDynamic: true
  })
  demandplan.setValue({
    fieldId: 'demandplancalendartype',
    value: 'MONTHLY'
  })
  demandplan.setValue({
    fieldId: 'subsidiary',
    value: 1
  })
  demandplan.setValue({
    fieldId: 'location',
    value: 1
  })
  demandplan.setValue({
    fieldId: 'item',
    value: 253
  })
  const id = demandplan.save({
    enableSourcing: true
  })
  
  const loadDemandPlan = record.load({
    type: record.Type.ITEM_DEMAND_PLAN,
    id: id,
    isDynamic: true 
  })
  loadDemandPlan.setValue({
    fieldId: 'startdate',
    value: '1/1/2023'
  })
  loadDemandPlan.setValue({
    fieldId: 'enddate',
    value: '12/31/2023'
  })
  loadDemandPlan.selectLine({
    sublistId: 'demandplandetail',
    line: '0'
  })
  loadDemandPlan.setCurrentSublistValue({
    sublistId: 'demandplandetail',
    fieldId: 'quantity_1_',
    value: 100
  })
  loadDemandPlan.selectLine({
    sublistId: 'demandplandetail',
    line: '1'
  })
  loadDemandPlan.setCurrentSublistValue({
    sublistId: 'demandplandetail',
    fieldId: 'quantity_1_',
    value: 200
  })
  loadDemandPlan.commitLine({
    sublistId: 'demandplandetail'
  })
  loadDemandPlan.save()
}) 

        

Weekly Demand Plan

A weekly demand plan includes a row for each week contained in the time period set by the body field start date and end date, and one quantity column for each week.

The Manual Item Demand Plan page with the weekly demand plan section highlighted.

Weekly Demand Plan Code Sample

The following sample sets quantities for the first two weeks of 2011:

          /**
 * @NApiVersion 2.1
 */

require(['N/record', 'N/log'], (record, log) => {
  const demandplan = record.create({
    type: record.Type.ITEM_DEMAND_PLAN,
    isDynamic: true
  })
  demandplan.setValue({
    fieldId: 'demandplancalendartype',
    value: 'WEEKLY'
  })
  demandplan.setValue({
    fieldId: 'subsidiary',
    value: 1
  })
  demandplan.setValue({
    fieldId: 'location',
    value: 1
  })
  demandplan.setValue({
    fieldId: 'item',
    value: 252
  })
  const id = demandplan.save({
    enableSourcing: true
  })
    
  const loadDemandPlan = record.load({
    type: record.Type.ITEM_DEMAND_PLAN,
    id: id,
    isDynamic: true 
  })
  loadDemandPlan.setValue({
    fieldId: 'startdate',
    value: '1/1/2023'
  })
  loadDemandPlan.setValue({
    fieldId: 'enddate',
    value: '12/31/2023'
  })
  loadDemandPlan.selectLine({
    sublistId: 'demandplandetail',
    line: '0'
  })
  loadDemandPlan.setCurrentSublistValue({
    sublistId: 'demandplandetail',
    fieldId: 'quantity_1_',
    value: 100
  })
  loadDemandPlan.selectLine({
    sublistId: 'demandplandetail',
    line: '1'
  })
  loadDemandPlan.setCurrentSublistValue({
    sublistId: 'demandplandetail',
    fieldId: 'quantity_1_',
    value: 200
  })
  loadDemandPlan.commitLine({
    sublistId: 'demandplandetail'
  })
  loadDemandPlan.save()
}) 

        

Daily Demand Plan

A daily demand plan includes a row for each week contained in the time period set by the body field start date and end date, and seven quantity columns for each week, one for each day of the week.

The Manual Item Demand Plan page with the daily demand plan section highlighted.

Daily Demand Plan Code Sample

          /**
 * @NApiVersion 2.1
 */

require(['N/record', 'N/log'], (record, log) => {
  const demandplan = record.create({
    type: record.Type.ITEM_DEMAND_PLAN,
    isDynamic: true
  })
  demandplan.setValue({
    fieldId: 'demandplancalendartype',
    value: 'DAILY'
  })
  demandplan.setValue({
    fieldId: 'subsidiary',
    value: 1
  })
  demandplan.setValue({
    fieldId: 'location',
    value: 1
  })
  demandplan.setValue({
    fieldId: 'item',
    value: 254
  })
  const id = demandplan.save({
    enableSourcing: true
  })
    
  const loadDemandPlan = record.load({
    type: record.Type.ITEM_DEMAND_PLAN,
    id: id,
    isDynamic: true 
  })
  loadDemandPlan.setValue({
    fieldId: 'startdate',
    value: '1/1/2023'
  })
  loadDemandPlan.setValue({
    fieldId: 'enddate',
    value: '12/31/2023'
  })
  loadDemandPlan.selectLine({
    sublistId: 'demandplandetail',
    line: '0'
  })
  loadDemandPlan.setCurrentSublistValue({
    sublistId: 'demandplandetail',
    fieldId: 'quantity_1_',
    value: 100
  })
  loadDemandPlan.selectLine({
    sublistId: 'demandplandetail',
    line: '1'
  })
  loadDemandPlan.setCurrentSublistValue({
    sublistId: 'demandplandetail',
    fieldId: 'quantity_1_',
    value: 200
  })
  loadDemandPlan.commitLine({
    sublistId: 'demandplandetail'
  })
  loadDemandPlan.save()
}) 

        

Matrix APIs for the Demand Plan Detail Sublist

Use the following matrix APIs with the Demand Plan Detail sublist:

Note:

With all APIs listed above, use the Record.selectLine(options) or CurrentRecord.selectLine(options) APIs first to select an existing line.

For more information about APIs, see N/currentRecord Module and N/record Module.

Related Topics

Demand Planning
Working with the SuiteScript Records Browser
SuiteCloud Supported Records
Transactions

General Notices