Kenneth Jules
01/16/2023, 9:13 PM// From "2021-08-19T00:00:00"
function convertStringToObj(timeString) {
if (timeString !== null && timeString !== "") {
var dateString =
timeString.substring(5, 7) +
"/" +
timeString.substring(8, 10) +
"/" +
timeString.substring(0, 4);
var d = new Date(dateString);
return d; //Expecting 08/19/2021
}
return "";
}
Watz
01/16/2023, 9:22 PMnew Date()
does not output a string. d would be a Date-objectKenneth Jules
01/16/2023, 9:23 PMKenneth Jules
01/16/2023, 9:23 PMWatz
01/16/2023, 9:24 PMWatz
01/16/2023, 9:26 PMKenneth Jules
01/16/2023, 9:30 PMAnthony OConnor
01/16/2023, 9:35 PMKenneth Jules
01/16/2023, 9:36 PMAnthony OConnor
01/16/2023, 9:37 PM"08/19/2021"
Anthony OConnor
01/16/2023, 9:37 PMAnthony OConnor
01/16/2023, 9:39 PMnew Date()
to get a date objectAnthony OConnor
01/16/2023, 9:40 PMWatz
01/16/2023, 9:40 PMAnthony OConnor
01/16/2023, 9:40 PMAnthony OConnor
01/16/2023, 9:42 PMfunction convertStringToObj(timeString) {
if (timeString !== null && timeString !== "") {
return new Date(timeString.substring(0,10))
}
return "";
}
Anthony OConnor
01/16/2023, 9:44 PMKenneth Jules
01/16/2023, 9:44 PMWatz
01/16/2023, 9:44 PMWatz
01/16/2023, 9:45 PMKenneth Jules
01/16/2023, 9:51 PMrecordLine.setValue(Obj.obj[fldMilestoneName], convertStringToObj(obj["obj"][fldMilestoneName]));
Anthony OConnor
01/16/2023, 9:52 PMObj.obj
vs. obj["obj"]
Kenneth Jules
01/16/2023, 9:56 PM{
"shipments": [
{
"milestones: {
"field": "2022-12-06T00:00:00Z"
}
}
]
}
Watz
01/16/2023, 9:57 PMWatz
01/16/2023, 9:58 PMWatz
01/16/2023, 9:58 PMAnthony OConnor
01/16/2023, 9:59 PMrecordLine.setValue({ fieldId: Obj.obj[fldMilestoneName],
value: convertStringToObj(obj["obj"][fldMilstonename])
});
Anthony OConnor
01/16/2023, 10:00 PMKenneth Jules
01/16/2023, 10:00 PMAnthony OConnor
01/16/2023, 10:01 PMKenneth Jules
01/16/2023, 10:01 PMAnthony OConnor
01/16/2023, 10:01 PMWatz
01/16/2023, 10:03 PMKenneth Jules
01/16/2023, 10:04 PMWatz
01/16/2023, 10:05 PMKenneth Jules
01/16/2023, 10:06 PMWatz
01/16/2023, 10:06 PMKenneth Jules
01/16/2023, 10:06 PMAnthony OConnor
01/16/2023, 10:07 PMAnthony OConnor
01/16/2023, 10:08 PMKenneth Jules
01/16/2023, 10:10 PMWatz
01/16/2023, 10:10 PMvar dateObj = convertStringToObj(obj["obj"][fldMilstonename])
log.debug(“check”,{value: dateObj, typeOf: typeof dateObj})
run this before your set value and verify that you get what you expect. Also change setValue to specify the parameters.Anthony OConnor
01/16/2023, 10:10 PMKenneth Jules
01/16/2023, 10:11 PMAnthony OConnor
01/16/2023, 10:12 PMrecordLine
is actually a custom record object reference?Anthony OConnor
01/16/2023, 10:13 PMsetValue
needs to look likeWatz
01/16/2023, 10:14 PMAnthony OConnor
01/16/2023, 10:16 PMWatz
01/16/2023, 10:18 PMbattk
01/17/2023, 1:26 AMbattk
01/17/2023, 1:27 AMbattk
01/17/2023, 1:27 AMbattk
01/17/2023, 1:27 AMbattk
01/17/2023, 1:28 AMKenneth Jules
01/17/2023, 2:58 PMKenneth Jules
01/17/2023, 3:53 PMZoran R-DATAGRAM
01/19/2023, 9:07 AMconst sefToUTCDateString = (tmpUtc) => {
// 01234567890123456789012----
// "2022-07-12T11:44:28.6089274+00:00"
const year = parseInt(tmpUtc.substring(0, 4));
const month = parseInt(tmpUtc.substring(5, 7)) - 1;
const day = parseInt(tmpUtc.substring(8, 10));
const hour = parseInt(tmpUtc.substring(11, 13));
const minute = parseInt(tmpUtc.substring(14, 16));
const seconds = parseInt(tmpUtc.substring(17, 19));
const tmpDate = new Date(year,month,day);
const sDate = format.format({
value: tmpDate,
type: format.Type.DATE
}); // formated as User Date Format, but only dd.mm.yyyy
const sDateTime = sDate + ' ' + hour + ":" + minute + ":" + seconds;
return (format.parse({
value: sDateTime,
type: format.Type.DATETIME,
timezone: format.Timezone.GMT
}));
}
Zoran R-DATAGRAM
01/19/2023, 9:09 AMZoran R-DATAGRAM
01/19/2023, 9:10 AMZoran R-DATAGRAM
01/19/2023, 9:16 AMbattk
01/19/2023, 9:25 AMbattk
01/19/2023, 9:27 AMbattk
01/19/2023, 9:28 AMbattk
01/19/2023, 9:29 AMnew Date("2022-07-12T11:44:28.6089274+00:00")
should get you the correct date, minus the nanosecondsZoran R-DATAGRAM
01/19/2023, 9:31 AMbattk
01/19/2023, 9:32 AMnew Date("2022-07-12T11:44:28.6089274+00:00")
and
new Date("2022-07-12T13:44:28.6089274+02:00")
are the same Datebattk
01/19/2023, 9:32 AMbattk
01/19/2023, 9:33 AMbattk
01/19/2023, 9:39 AMZoran R-DATAGRAM
01/19/2023, 9:39 AMtmpDateTime = new Date("2022-07-12T11:44:28.6089274+00:00")
sefPurchaseRecord.setValue({
fieldId: 'custrecord_rdata_sef_pi_lastmodified', // DATETIME field type
value: tmpDateTime
});
Above code is running in M/R
So your final instruction is to use +00:00 to set GMT / UTC zone if I know that)\
Zoran R-DATAGRAM
01/19/2023, 9:44 AMbattk
01/19/2023, 9:45 AMbattk
01/19/2023, 9:46 AMbattk
01/19/2023, 9:47 AMbattk
01/19/2023, 9:47 AMZoran R-DATAGRAM
01/19/2023, 9:48 AMbattk
01/19/2023, 9:48 AMbattk
01/19/2023, 9:49 AMbattk
01/19/2023, 9:49 AMZoran R-DATAGRAM
01/19/2023, 10:01 AMZoran R-DATAGRAM
01/19/2023, 10:07 AMZoran R-DATAGRAM
01/19/2023, 10:09 AMZoran R-DATAGRAM
01/19/2023, 10:45 AMbattk
01/19/2023, 10:56 AMbattk
01/19/2023, 10:56 AMbattk
01/19/2023, 10:57 AMbattk
01/19/2023, 10:58 AMbattk
01/19/2023, 11:03 AMbattk
01/19/2023, 11:03 AMbattk
01/19/2023, 11:04 AMbattk
01/19/2023, 11:05 AMnew Date("2022-07-12T11:44:28.6089274+00:00")
and
new Date("2022-07-12T13:44:28.6089274+02:00")
reprresent the same DateZoran R-DATAGRAM
01/19/2023, 1:25 PMZoran R-DATAGRAM
01/19/2023, 2:00 PMbattk
01/19/2023, 6:19 PMbattk
01/19/2023, 6:21 PMbattk
01/19/2023, 6:22 PMZoran R-DATAGRAM
01/19/2023, 6:30 PM