https://netsuiteprofessionals.com logo
s

screnshaw

05/05/2022, 8:32 PM
any idea as to why this would be causing an infinite loop on a client script? I have a script, that when the total reaches a certain point, checks this box. For some reason, it is on an infinite loop. According to the fieldChange log, the one causing the infinite loop is when the
custbody_mhi_ad_charge_freight_once
is checked. Also when I comment it out, it works
Copy code
if (freight.amt === 0) {
            newRec.setValue({
                fieldId: 'custbody_mhi_ad_freight_override',
                value: true,
                ignoreFieldChange: true
            });
        }

        newRec.setValue({
            fieldId: 'custbody_mhi_ad_freight_rate',
            value: freight.amt,
            ignoreFieldChange: true
        });

        // If it is a hard value and not a percent value, charge freight once
        newRec.setValue({
            fieldId: 'custbody_mhi_ad_charge_freight_once',
            ignoreFieldChange: !freight.isPct,
            value: true
        });
b

battk

05/05/2022, 8:36 PM
not enough code, usual guesses are either a fieldChanged or validateField entrypoint
s

screnshaw

05/05/2022, 8:36 PM
I'm not sure what other code to give, but here is the client script.
Copy code
function fieldChanged(ctx) {
    const fields = ['shipmethod', 'entity', 'custbody_mhi_ad_order_type', 'custbody_mhi_ad_charge_freight_once'];
    if (fields.includes(ctx.fieldId)) {
        log.debug('ctx', {
            record: ctx.currentRecord,
            sublistId: ctx.sublistId,
            fieldId: ctx.fieldId,
            lineNum: ctx.lineNum,
            columnNum: ctx.columnNum
        });
        // log.debug('fieldChanged', ctx.fieldId);
        freightHelper.setFreight(ctx);
    }
}
Those 2 blocks are the only significant blocks. The rest of the script is calculating data and then using those 3 setValues above, to set the data
b

battk

05/05/2022, 8:38 PM
not enough was shared to tell if ignoreFieldChange is true or not
s

screnshaw

05/05/2022, 8:38 PM
OHHHH. sorry. I currently have it hardcoded to true
i just noticed it
the 3rd one has them out of order
has the properties out of order so the ignoreFieldChange is looking at the actual value