We have a simple Client script that we had help writing. it sets the taxcode/rate to a default value. But we still want to be able edit that field after the fact, and right now, it doesn't let us. The use case basically is we have a retail location and the tax codes need to be the same for all UI created cash sales (to overwrite Avalara), but sometimes, customers are tax exempt, and we need to switch the tax code to not taxable. I've tried playing around with the conditions in the if statement, but no luck. it feels like their should be some sort of property to allow editing after the fact though that I don't know about?
/** * @NApiVersion 2.x * @NScriptType ClientScript * @NModuleScope SameAccount */define(['N/record'],function(record) { /** * Function to be executed after page is initialized. * * @param {Object} scriptContext * @param {Record} scriptContext.currentRecord - Current form record * @param {string} scriptContext.mode - The mode in which the record is being accessed (create, copy, or edit) * * @since 2015.2 */ function pageInit(scriptContext) { } /** * Function to be executed when field is changed. * * @param {Object} scriptContext * @param {Record} scriptContext.currentRecord - Current form record * @param {string} scriptContext.sublistId - Sublist name * @param {string} scriptContext.fieldId - Field name * @param {number} scriptContext.lineNum - Line number. Will be undefined if not a sublist or matrix field * @param {number} scriptContext.columnNum - Line number. Will be undefined if not a matrix field * * @since 2015.2 */ function fieldChanged(scriptContext) { try{ var sublistName = scriptContext.sublistId; var sublistFieldName = scriptContext.fieldId; var currentRecord = scriptContext.currentRecord; if(sublistName == 'item' && (sublistFieldName == 'item' || sublistFieldName == 'taxcode' || sublistFieldName == 'taxrate1')){ currentRecord.setCurrentSublistValue({sublistId:sublistName ,fieldId: 'taxcode', value: -251, ignoreFieldChange: true}); currentRecord.setCurrentSublistValue({sublistId:sublistName ,fieldId: 'taxrate1', value: 8.625, ignoreFieldChange: true}); } }catch(ex){ } } return { pageInit: pageInit, fieldChanged: fieldChanged, }; });