Find the First occurrence of the item in sales order

Scenario: When creating a sales order record, we need to check whether the newly added item is already added or not. So for that use the following code section in the client script.

 let currentRecord = scriptContext.currentRecord;
FIRST_OCCURENCE = currentRecord.findSublistLineWithValue({
                            sublistId: 'item',
                            fieldId: 'item',
                            value: 123   // Item Id
                        });

Returns the line number for the first occurrence of a field value in a sublist. This will return -1 if searching item is not found.

Leave a comment

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