Use of currentrecord.commitLine(Options) Method with the currentrecord.setCurrentSublistValue(Options) Method via SuiteScript 2.0 Client Script

User would like to set a sublist field’s value on a List Type Sublist using the currentRecord.setCurrentSublistValue(options) method and setting the ignoreFieldChange option to true. There are no errors encountered on the script but the sublist field’s value is not reflected correctly to the UI. The reason for this behavior is because the line item is not committed yet.

Since the line item is not committed yet, the use of the currentRecord.commitLine(options) method is needed.

Sample code

define(['N/record'],function(record) {
	function fieldChanged(context) {
		var currentRecord = context.currentRecord;
		var currentItem = currentRecord.getCurrentSublistValue({
			'sublistId':'item',
			'fieldId':'item'
		});

		if (currentItem != null || currentItem != ""){
			currentRecord.setCurrentSublistValue({
				'sublistId':'item',
				'fieldId':'description',
				'value':'Hello',
				'ignoreFieldChange':true
			});
			currentRecord.commitLine({sublistId:'item'});
		}
	}
    return {
    	fieldChanged:fieldChanged
    };
});

Leave a comment

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