We can select an item from a sublist using the index. If we use the line index we can use the selectLine() function for this.
We can also calculate the index value using the line Id. The line id is usually one value greater than the index value. But this can be different if some items are removed and new items are added.
In this case, an ideal solution is to use the ‘lineuniquekey’ sublist field. This value will not be changed even if any lines are removed.
Refer to the code below:
// Inside loop
var lineNumWithKey = objRecord.findSublistLineWithValue({// Find line with correct unique key
    sublistId: 'item',
    fieldId: 'lineuniquekey',
    value: selectedLineUniqueKeyArr[i]
});
log.debug("lineNumWithKey", lineNumWithKey);
objRecord.selectLine({
    sublistId: 'item',
    line: lineNumWithKey
});
objRecord.setCurrentSublistValue({
    sublistId: 'item',
    fieldId: 'rate',
    value: price,
    ignoreFieldChange: false,
    forceSyncSourcing: true
});
objRecord.commitLine({
    sublistId: 'item'
});