How can I set a UTC date-time value in NetSuite us...
# ask-stanley-ai
v
How can I set a UTC date-time value in NetSuite using a script? I received the following date and time from a HubSpot API response:
2025-06-24T03:00:00Z
. I want to set this value to a time field in NetSuite using a script.
c
AI generated answer (using internal Slack threads):
To set a UTC date-time value in NetSuite using a script, you can use the
setValue
method of the
record
module in SuiteScript. The
setValue
method allows you to set the value of a field on a record. The date-time value you received from the HubSpot API response is in ISO 8601 format and it's in UTC. JavaScript's
Date
object can parse this format directly. Here is a sample script:
Copy code
javascript
var record = require('N/record');
var myRecord = record.load({
    type: 'customrecord_my_custom_record', 
    id: '123'
});

var dateTimeValue = new Date('2025-06-24T03:00:00Z');
myRecord.setValue({
    fieldId: 'custrecord_my_datetime_field',
    value: dateTimeValue
});

var recordId = myRecord.save();
In this script, replace
'customrecord_my_custom_record'
with the ID of the record type you're working with, replace
'123'
with the ID of the specific record you want to update, and replace
'custrecord_my_datetime_field'
with the ID of the field you want to set the date-time value to. Please note that the
Date
object in JavaScript uses the local time zone of the machine where the code is running. However, since the date-time string you're passing to the
Date
constructor is in UTC (indicated by the 'Z' at the end), the
Date
object will represent the correct point in time. ****** Disclaimer: This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes. ******
Slack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.84198916
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.83206
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.830981672
Please provide your feedback on this answer.
Thank you for your feedback