Anyone who can help a newbie with a suitescript2.0...
# suitescript
b
Anyone who can help a newbie with a suitescript2.0 training question? Getting a reference error and not sure what is wrong
b
ask the actual question
b
Just unsure what is causing the Reference Error in the following script, again new to SuiteScript & JavaScript so any advice would be appreciated
Copy code
function fieldChanged(context) {
        var customer = context.newRecord
        var applyCoupon = customer.getValue('custentity_sdr_apply_coupon');
        var couponCode = customer.getValue('custentity_sdr_coupon_code');
        //if apply coupon is checked enable coupon code, if unchecked disable coupon code and erase its content
        if (!applyCoupon) {couponCode.isDisabled = true;
        } else {couponCode.isDisabled = false;
        }

    }
b
you should share the actual error
but that fieldChanged function is missing an essential step
fieldChanged entryPoints run whenever any field is changed
they should always have some sort of logic to prevent them from running on unrelated changes
b
gotcha that makes sense, I appreciate the help
b
you still probably want to share that error, my comment was more in general
your reference error probably still exists (though made worse without the filtering you are missing)