To achieve such behavior, do the following steps:
A. Create a new Transaction Line Field.
1. Navigate to Customization > Lists, Records, & Fields >Transaction Line Fields > New.
a. Label: Line
b. Field Type: Integer Number
c. ID: _line_number
d. Store Value: T
2. Apply it to transaction by marking the checkbox that can be seen on the Applies To subtab.
3. Save.
B. Create and Deploy the User Event script.
1. Navigate to Customization > Scripting > Scripts > New
The system displays the Upload Script File page.
2. Upload the script file with the script below:
function beforeSubmit(scriptContext) {
var rec = scriptContext.newRecord;
var lineCount = rec.getLineCount({sublistId: 'item'});
for ( var lineNumber = 0 ; lineNumber < lineCount ; lineNumber++){
rec.setSublistValue({
sublistId: 'item',
fieldId: 'custcol_line_number',
line: lineNumber,
value: lineNumber + 1
});
}
}
Click Create Script Record
4. Enter the following details:
a. Name: AddLineCountPerLine
5. Click Save and Deploy
6. Enter the following details:
a. Applies to: Order
b. Status: Released
c. Roles: All
7. Click Save
After following the said procedures, line number on the line item will now be shown upon saving the transaction record.