Interesting to see struggles with Netsuite dates ...
# suitescript
m
Interesting to see struggles with Netsuite dates today. I am one step behind @jmacdonald today. I have been struggling with what should be another simple(r?) task. Take the invoice date, add 365 days, and assign that to a different, custom field....
Copy code
var invoiceDate = new Date(invoiceRecord.getValue({ fieldId:'trandate'}));
		var futureDate = new Date(invoiceDate.toString());		
		futureDate.setDate(futureDate.getDate() + 365);
That said, when I run the above code in the NS debugger, once "futureDate.setDate()" is run, I see the value of both "futureDate" AND "invoiceDate" increment by 365 days. Bonkers. Why is the value of "invoiceDate" changing in the debugger? I would have thought the "new Date(invoiceDate.toString()) would have effectively decoupled any sort of "variable referencing" going on.
🤔 1