Hi,
Following on from my previous question, the script is now working, but the date comparison part of it isn't working quite as I expected.
The check should ensure that if a date before today is selected as the due date, an error message comes up. I thought the code below would allow users to select today's date, or any date in the future. In practice, selecting today's date triggers the error message.
Please could you tell me what I've done wrong.
Thanks,
Sam.
function saveSOCheck()
{
// Validate due date
var despatchDueDateValue = nlapiGetFieldValue('custbody_despatch_due_date');
var despatchDueDate = nlapiStringToDate(nlapiGetFieldValue('custbody_despatch_due_date'));
var today = new Date();
if ((despatchDueDate < today) && (nlapiGetFieldValue('custbody_on_hold') == 'F') )
{
alert("Despatch Due Date day must be future date");
return false;
}
// Validate credit hold
var custId = nlapiGetFieldValue('entity');
var creditHold = nlapiLookupField('customer', custId, 'credithold');
if (creditHold == 'ON')
{
alert ("Customer on Hold. Do not accept order, please inform Kate that this customer attempted to place an order.");
return false;
}
return true;
}