Tuesday, February 19, 2019

Line ID vs. Line Sequence Number

A NetSuite user would like to use a Transaction Search in order identify the line items which meet a certain criteria and modify these using SuiteScript. In order to modify the line items with setLineItemValue(name, linenum, value) the corresponding line number is needed. Looking at the available search columns the user is asking what to choose between Line ID (field internal id: line) and Line Sequence Number (field internal id: linesequencenumber) in order to obtain the line number parameter expected by setLineItemValue(name, linenum, value).

The Line Sequence Number holds the internal sequence number stored for each transaction line according to the line item's position in the sublist and is the value expected by the nlobjSublist methods setLineItemValue(name, linenum, value) and getLineItemValue(group, fldnam, linenum).
The Line ID is not related to the line item's position in the sublist. Each line item is given a Line ID when it is created, which does not change until the line is removed regardless of the performed operations (e.g. editing the line, inserting a line item above). If the line item is removed and another line item is inserted to replace it, the new line item will have a different Line ID, but the same Line Sequence Number.

In order to illustrate the difference between the Line ID and the Line Sequence Number, consider the Sales Order #123, whose items sublist contains three line items and the following Transaction Search:
  • Type is Sales Order
  • Number is 123
  • Memo is not VAT
  • Main Line is false
  • Type
  • Number/ID
  • Item
  • Memo
  • Line ID
  • Line Sequence Number
The Search returns three results, the three line items from the Sales Order. If the original line items have not been removed, then the Line ID and the Line Sequence Number are equal.
Item Line ID Line Sequence Number
Item 1 1 1
Item 2 2 2
Item 3 3 3

Editing the existing line items does not affect the Line IDs or Line Sequence Numbers, however after deleting line items and adding new ones the Line IDs are different from the Line Sequence Numbers. For example, if the first Item is removed from the Sales Order, then the values of Line ID and Line Sequence Number are no longer the same:
Item Line ID Line Sequence Number
Item 2 2 1
Item 3 3 2

1 comment: