Vernita
04/18/2024, 10:02 AMvar currentDate = new Date();
var formattedDate = format.format({
value: currentDate,
type: format.Type.DATE,
timezone:format.Timezone.PACIFIC_AUCKLAND
});
log.debug("formattedDate", formattedDate);
When I use the resulting value to set a date field on the custom record, I receive the error per the screenshot.
I assume this is because the formattedDate variable is a string?
I have tried to use this to convert the string to a date format.
var parsedDate= format.parse({
value:formattedDate,
type: format.Type.DATE
});
log.debug("parsedDate",parsedDate)
However, this returns a date/time object in a different format
Can anyone see where I am going wrong with this?battk
04/18/2024, 12:57 PMbattk
04/18/2024, 12:57 PMbattk
04/18/2024, 12:58 PMVernita
04/18/2024, 11:21 PMVernita
04/18/2024, 11:22 PMbattk
04/19/2024, 5:14 AMbattk
04/19/2024, 5:15 AMbattk
04/19/2024, 5:15 AMbattk
04/19/2024, 5:15 AMVernita
04/19/2024, 7:39 AMsampleRequest.setValue({
fieldId: "custrecord_request_date",
value: formattedDate,
});
Does that make sense?battk
04/19/2024, 7:48 AMbattk
04/19/2024, 7:50 AMbattk
04/19/2024, 7:51 AMVernita
04/19/2024, 8:21 AMbattk
04/19/2024, 8:35 AMbattk
04/19/2024, 8:46 AMbattk
04/19/2024, 8:47 AMbattk
04/19/2024, 8:51 AMVernita
04/19/2024, 10:03 AMbattk
04/19/2024, 5:17 PMbattk
04/19/2024, 5:20 PMbattk
04/19/2024, 5:21 PMbattk
04/19/2024, 5:21 PMVernita
05/11/2024, 10:26 AMvar currentDate = new Date();
var formattedDate = format.format({
value: currentDate,
type: format.Type.DATETIME,
timezone:format.Timezone.AUSTRALIA_SYDNEY
});
log.debug("formattedDate", formattedDate);
var parsedDateStringAsRawDateObject = format.parse({
value: date,
type: format.Type.DATE
});
the format.format function with enum value under timezone returns the correct date in the specified timezone
Where I was going wrong was the formattedDate
variable:
Under type, I had:
type: format.Type.DATE
this needed to be
type: format.Type.DATETIME,
The custom field , being set by the Suitelet, is type 'Date'. However, the conversion to date occurs with parsedDateStringAsRawDateObject
which sets the field value to the required date formatTM_Kev
06/24/2024, 3:13 AM