如何使用客户端脚本 (SuiteScript 2.0) 在不禁用整个列的情况下禁用行项目字段?

How can I disable line item field without disabling entire column using Client Script (SuiteScript 2.0)?

我正在尝试禁用子列表字段,以填充另一个子列表字段。但是,在我看来它不起作用。 我使用了 lineInit(因为它看起来像我现在需要的)。

function lineInit(context) {

        var cr = context.currentRecord;
        var selectedLine = cr.getCurrentSublistIndex({sublistId: "item"});
        var iskontoOran = cr.getCurrentSublistValue({sublistId: "item", fieldId : "custcol_delta_iskonto_oran"});
        if (iskontoOran != "0.00"){
            cr.getCurrentSublistValue({sublistId : "item", fieldId: "custcol_delta_iskonto_tutar", line: 0
            }).isDisabled = true;
        }
        else {
            cr.getCurrentSublistValue({sublistId : "item", fieldId: "custcol_delta_iskonto_tutar", line: 0
            }).isDisabled = false;
        }
function lineInit(context) {
    var cr = context.currentRecord;
    var iskontoOran = cr.getCurrentSublistValue({sublistId: "item", fieldId : "custcol_delta_iskonto_oran"});
    cr.getSublistField({sublistId : "item", fieldId: "custcol_delta_iskonto_tutar"}).isDisabled = iskontoOran != 0;
}

function fieldChanged(context) {
    var cr = context.currentRecord;
    var sublistName = context.sublistId;
    var sublistFieldName = context.fieldId;
    if (sublistName === 'item' && sublistFieldName === 'custcol_delta_iskonto_oran') {
        var iskontoOran = cr.getCurrentSublistValue({sublistId: "item", fieldId : "custcol_delta_iskonto_oran"});
        cr.getSublistField({sublistId : "item", fieldId: "custcol_delta_iskonto_tutar"}).isDisabled = iskontoOran != 0;
    }
}
     function fieldChanged(context) {
        var myRec = context.currentRecord;
        var itemCount = myRec.getLineCount("item");
        var anlıkLine = myRec.getCurrentSublistIndex({ sublistId: "item" });
        var sublistName = myRec.getSublist({sublistId: "item"});
        var oranColumn = sublistName.getColumn({ fieldId: "custcol_delta_iskonto_oran" });
        var tutarColumn = sublistName.getColumn({ fieldId: "custcol_delta_iskonto_tutar" });
        var currOran = myRec.getCurrentSublistValue({ sublistId: "item", fieldId: "custcol_delta_iskonto_oran" });
        var currTutar = myRec.getCurrentSublistValue({ sublistId: "item", fieldId: "custcol_delta_iskonto_tutar" });
        if (currTutar) {
            myRec.setCurrentSublistValue({
                sublistId: "item",
                fieldId: "custcol_delta_iskonto_oran",
                value: "",
                ignoreFieldChange: true
            });
            oranColumn.isDisabled = true;
        } else {
            oranColumn.isDisabled = false;
        }
        if (currOran) {
            myRec.setCurrentSublistValue({
                sublistId: "item",
                fieldId: "custcol_delta_iskonto_tutar",
                value: "",
                ignoreFieldChange: true
            });
            tutarColumn.isDisabled = true;
        } else {
            tutarColumn.isDisabled = false;
        }
}
function lineInit(context) {
        var myRec = context.currentRecord;
        var itemCount = myRec.getLineCount("item");
        var anlıkLine = myRec.getCurrentSublistIndex({ sublistId: "item" });
        var quantity = myRec.getCurrentSublistValue({ sublistId: "item", fieldId: "quantity" });
        log.debug({ title: "AnlıkLine, Quantity ve itemCount-LineInit", details: "anlıkLine = " + anlıkLine + ", quantity = " + quantity + ", itemcount = " + itemCount });
        for (var j = 0; j < itemCount; j++) {
            if (quantity){
                var oranField = myRec.getSublistField({ sublistId: "item", fieldId: "custcol_delta_iskonto_oran", line: j });
                var tutarField = myRec.getSublistField({ sublistId: "item", fieldId: "custcol_delta_iskonto_tutar", line: j });
                var currOran = myRec.getCurrentSublistValue({ sublistId: "item", fieldId: "custcol_delta_iskonto_oran" });
                var currTutar = myRec.getCurrentSublistValue({ sublistId: "item", fieldId: "custcol_delta_iskonto_tutar" });
                if (currTutar) {
                    myRec.setCurrentSublistValue({
                        sublistId: "item",
                        fieldId: "custcol_delta_iskonto_oran",
                        value: "",
                        ignoreFieldChange: true
                    });
                    oranField.isDisabled = true;
                } else {
                    oranField.isDisabled = false;
                }
                if (currOran) {
                    myRec.setCurrentSublistValue({
                        sublistId: "item",
                        fieldId: "custcol_delta_iskonto_tutar",
                        value: "",
                        ignoreFieldChange: true
                    });
                    tutarField.isDisabled = true;
                    log.debug({ title: "Tutar Alanı 
                } else {
                    tutarField.isDisabled = false;
                }
            }
        }
    }

这是我的方法,目前效果很好。能再好看点吗?是的,可能,但它现在确实可以完成工作:)