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

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

Asked 1 years ago
0
4 answers

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

Source: link

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

So this is my aproach and it is working fine at the moment. Can it be more nice? Yeah, probably but it does do the job for now :)

Source: link

0

-Use the NetSuite example as a base, to prevent the line from editing you just have to return false.
function sampleValidateLine(type)
{
    if ( (nlapiGetCurrentLineItemValue('item', 'custcol_service_item') == true) &&
        (!nlapiGetCurrentLineItemText('item', 'custcol_service_rep')) )
    {
        alert("You must choose a Service Rep for this service item.");
        return false;
    }
    return true;
}

Source: link

0

To temporarily turn off ESLint, you should add a block comment /* eslint-disable */ before the lines that you’re interested in:
/* eslint-disable */
console.log('JavaScript debug log');
console.log('eslint is disabled now');
To turn it back on you should use the block comment /* eslint-enable */.
/* eslint-disable */
console.log('JavaScript debug log');
console.log('eslint is disabled now');
/* eslint-enable */
To disable not all, but only some specific ESLint rules, you should list them in the same comment. Split the rules with commas:
/* eslint-disable no-console, no-control-regex*/
console.log('JavaScript debug log');
console.log('eslint is disabled now');
The rules eslint-disable and eslint-enable should always be placed in the block comments. This doesn’t work:
// eslint-disable no-console, no-control-regex
console.log('JavaScript debug log');
console.log('eslint is disabled now');
To turn off linter for the current line, you add a comment after that line:
console.log('eslint is disabled for the current line'); // eslint-disable-line

Source: link

Recent Questions on netsuite

    Programming Languages