I had hell of time today trying to assign a Date/Time value to a custom entity variable. There is no documentation on how to do this on Netsuite or SERP on Google. I ended up finding an answer by trial-and-error after spending fair amount of time. The setFieldValue method takes a String value as an input, so the date/time value must be a String. I've tried a half dozen different formats including string conversions using the nlapiDateToString and nlapiStringToDate methods, but none of those worked.
2012-06-06 00:00:00 // SQL format
2012-06-06T00:00:00-06:00 // ISO 8601 format
06/06/2012 00:00:00 // Per user preferences setting
1339002061000 // In milliseconds
The solution was to add Ante meridiem (am) or Post meridiem (pm) value at the end of the format as shown below.
[Solved] Assigning Date/Time field via setFieldValue
I had hell of time today trying to assign a Date/Time value to a custom entity variable. There is no documentation on how to do this on Netsuite or SERP on Google. I ended up finding an answer by trial-and-error after spending fair amount of time. The setFieldValue method takes a String value as an input, so the date/time value must be a String. I've tried a half dozen different formats including string conversions using the nlapiDateToString and nlapiStringToDate methods, but none of those worked.
2012-06-06 00:00:00 // SQL format
2012-06-06T00:00:00-06:00 // ISO 8601 format
06/06/2012 00:00:00 // Per user preferences setting
1339002061000 // In milliseconds
The solution was to add Ante meridiem (am) or Post meridiem (pm) value at the end of the format as shown below.
customer.setFieldValue('custentity_createdate', ‘06/06/2012 06:00:00 pm’);
It is worthwhile to use the UI form to manually insert a record, and it will help you identify the problem or hint you to a solution.