Hello, trying to prevent Item Receipt transaction ...
# suitescript
t
Hello, trying to prevent Item Receipt transaction saving if bin numbers are missing. it works for empty bin number fields but it also gives error when i enter the bin number values, any idea what is wrong?
"/ "** * @NApiVersion 2.x * @NScriptType ClientScript * @AppliesTo Record Item Receipt */ define(['N/ui/message'], function(message) { function saveRecord(context) { var currentRecord = context.currentRecord; // Get the value of the bin field var binValue = currentRecord.getValue({ fieldId: 'binnumber' }); // Check if the bin field is null or empty if (!binValue) { // Show a pop-up message if the bin field is empty message.create({ title: 'Bin Field is Empty', message: 'Please fill in the bin field', type: message.Type.ERROR }).show(); // Do not save the record return false; } // Save the record if the bin field is not empty return true; } return { saveRecord: saveRecord }; });
b
learn how to use either the debugger or the console to check the value of the binValue variable