Dear all experts,
We have 1 script "PS | UE | Apply processes to Trans", there is a "ps_lib_SORef Check.js" in libraries, this script for sales order and credit note to detect duplicated customer PO Reference for the same customer when enter sales order. Similar to credit note, if any GRN Number duplicated for the same customer, it will return an error and will stop user from saved the transaction. Using same field (otherrefnum) for both sales order and credit note.
Recently we found we have 3 credit note for the same GRN no / Reference No.
We also have duplicated sales order for same PO reference No.
How to add the checking for PO reference no by remove the "space" when user key in the reference no : "DM202270" + space OR "DM202270 " ?
Below are the statement in "ps_lib_SORef Check.js", how to avoid user from saving the transaction if user enter space at the end of reference no.
if (searchResults != null && searchResults.length > 0) {
// Throw an error
// If exsiting SO is being editted and results aren't the current SO then error
if (!isNullOrEmpty(idRec) && searchResults.length > 0) {
nlapiLogExecution('DEBUG', objname, 'RecType: ' + rec_type + ';' + idRec + ';' + searchResults.length + ';');
var boolFnd = true;
if (searchResults.length == 1 && searchResults[0].getId() == idRec)
boolFnd = false;
if (boolFnd) {
throw nlapiCreateError('998', 'GRN No./PO No.'+poNum+' is already used by this customer'+soNum+' - Check transaction duplicate detected!');
boolRes = false;
}
}
// If no existing SO being editted and results then error
if (isNullOrEmpty(idRec)) {
nlapiLogExecution('DEBUG', objname, 'RecType: ' + rec_type + ';' + idRec + ';' + searchResults.length + ';');
throw nlapiCreateError('998', 'GRN No./PO No.'+poNum+' is already used by this customer'+soNum+' - Check transaction the duplicate detected!');
boolRes = false;
}
}
Thanks in advance !
Best Regards,
Bee Yook