- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-06-2023 01:57 PM
I have the following function in a script include:
glideDateTimeToISO: function(glideDateTime) {
var isoDate = new Date(glideDateTime.getNumericValue()).toISOString();
return isoDate;
}
It takes in a GlideDateTime object. Problem is when I call the function from a business rule with:
var isoTimeDate = myUtils.glideDateTimeToISO((gr.event_datetime));
where gr.event_datetime is a DateTime field, I get the following error:
"TypeError: Cannot find function getNumericValue in object 2023-08-04 04:00:00."
How do you pass an object from a business rule to a script include?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-06-2023 02:44 PM
Hi, I think your issue is the way you are attempting to utilize the GlideDateTime methods.
testing in an OOB PDI background window I think something like will work.
function glideDateTimeToISO(myTime) {
var gdt = new GlideDateTime(myTime);
var isoDate = new Date(gdt.getNumericValue()).toISOString();
return isoDate;
}
var test = new GlideRecord('incident');
test.get('57af7aec73d423002728660c4cf6a71c');
var isoTimeDate = glideDateTimeToISO(test.opened_at);
gs.info('isoTimeDate ' + isoTimeDate);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-06-2023 02:44 PM
Hi, I think your issue is the way you are attempting to utilize the GlideDateTime methods.
testing in an OOB PDI background window I think something like will work.
function glideDateTimeToISO(myTime) {
var gdt = new GlideDateTime(myTime);
var isoDate = new Date(gdt.getNumericValue()).toISOString();
return isoDate;
}
var test = new GlideRecord('incident');
test.get('57af7aec73d423002728660c4cf6a71c');
var isoTimeDate = glideDateTimeToISO(test.opened_at);
gs.info('isoTimeDate ' + isoTimeDate);