NetSuite Client Script 2.0 to Disable Expiry Date Sublist Field on Inventory Detail record

676 views Asked by At

I'm trying to disable the display type of expiry date field on inventory details. The current client script is working for 1st line only or 0 index. I'm trying to completely disable this field for all lines while adding inventory details.

This is my script please tell me what I missed here.

Thanks

function lineInit(scriptContext) {
        try {
            var currentRecord = scriptContext.currentRecord;
            var sublistId = scriptContext.sublistId;

            if (sublistId !== 'item') return;

            var selectedLine = currentRecord.getCurrentSublistIndex({
                sublistId: 'item'
            });

            log.debug({ title: 'selectedLine', details: JSON.stringify(selectedLine) });

            var inventoryDetail = currentRecord.getCurrentSublistSubrecord({
                sublistId: "item",
                fieldId: "inventorydetail"
            });

            var expiryDate = inventoryDetail.getCurrentSublistField({
                sublistId: "inventoryassignment",
                fieldId: "expirationdate"
            });

            expiryDate.isDisabled = true;

        } catch (error) {
            log.debug({ title: 'Catch Error', details: error });
        }
    }
1

There are 1 answers

0
Addy On

you need to traverse the loop using

var numLines = objRecord.getLineCount({ sublistId: 'item' });

for the inventory detail sublist (summary) similarly as we do for item sublist then only it will set all the expiry dates to disabled , you have just taken the index "selectedLine" and printed in the log