Invalid date value
Hello everyone, the following code gives me this warning in netsuite: Invalid date value(must be DD/MM/YYY)
/**
*@NApiVersion 2.x
*@NScriptType UserEventScript
*/
define([‘N/record’], function (record) {
function beforeLoad(context) {
}
function beforeSubmit(context) {
}
function afterSubmit(context) {
// carregar registro
var curRec = context.newRecord;
//pega a data de vencimento atual
var transDueDate = curRec.getValue({
fieldId: ‘duedate’
});
//pega a condição de pagamento
var transTerms = curRec.getValue({
fieldId: ‘terms’
});
//string vazia que mantém o campo terms como um número de dias
var addtlDays;
//transforma o campo terms em um número de dias
switch (transTerms) {
case 1:
//Ex: 1 = id terms “Net 15”
addtlDays = 15;
break;
case 2:
// Ex: 2 = id terms “Net 30”
addtlDays = 30;
break;
// adicione declarações de caso adicionais conforme necessário
default:
addtlDays = 0;
}
//calcula a nova data de vencimento
var d = new Date(transDueDate);
var newDueDate = d.setDate(d.getDate() + addtlDays);
//define a nova data de vencimento
curRec.setValue({
fieldId: ‘duedate’,
value: newDueDate,
ignoreFieldChange: true
// opcional, o padrão é falso
});
}
return {
beforeLoad: beforeLoad,
beforeSubmit: beforeSubmit,
afterSubmit: afterSubmit
}
});