Difference Between nlapiGetCurrentLineItemValue or record.getCurrentSublistValue and nlapiGetLineItemValue or record.getSublistValue

There are two functions for accessing line items in sublists.

 

For SuiteScript 1.0:

nlapiGetCurrentLineItemValue() and nlapiGetLineItemValue()

 

For SuiteScript 2.0:

record.getCurrentSublistValue() and record.getSublistValue()

 

These two functions perform the same in most contexts except Client scripts. In Client scripts, the retrieved values can be different. 

 

The nlapiGetCurrentLineItemValue() or record.getCurrentSublistValue() should be used to pull the new value that is being compared/validated/recalculated in Edit Mode.

 

Use nlapiGetLineItemValue() or record.getSublistValue() to get the old/state value.

Example: The quantity on the Sales Order item Item1 is 5. Then in edit mode, the quantity of the Item1 is changed from 5 to 7.

Solution

To get the old value 5, use:

SuiteScript 1.0
nlapiGetLineItemValue('item', 'quantity', 1);

 
SuiteScript 2.0
record.getSublistValue({
  sublistId: "item",
  fieldId: "quantity",
  line: 0
});

 
To get the new just entered value 7, use:
 
SuiteScript 1.0
nlapiGetCurrentLineItemValue('item', 'quantity');

 
SuiteScript 2.0
record.getCurrentSublistValue({
  sublistId: "item",
  fieldId: "quantity"
});

Leave a comment

Your email address will not be published. Required fields are marked *