首页 > 解决方案 > NetSuite 客户端脚本 2.0 禁用库存明细记录中的到期日期子列表字段

问题描述

我正在尝试禁用库存详细信息中到期日期字段的显示类型。当前客户端脚本仅适用于第一行或 0 索引。我正在尝试在添加库存详细信息时完全禁用所有行的此字段。

这是我的脚本,请告诉我我在这里错过了什么。

谢谢

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 });
        }
    }

标签: netsuitesuitescriptsuitescript2.0clientscriptsuitescript1.0

解决方案


你需要遍历循环使用

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

对于库存详细信息子列表(摘要),就像我们对项目子列表所做的那样,只有它将所有到期日期设置为禁用,您刚刚获取索引“selectedLine”并打印在日志中


推荐阅读