- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi,
I need to transform timestamps into dates.
I try to use GlideDateTime in an EVAL script during table transformation, but I'm always getting an error.
Does anyone know, if it's in general supported, I couldn't find it documented and in the EVAL script examples kb article is no reference/ use of GlideDateTime.
Thanks for your support in advance
Thomas
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago - last edited 3 weeks ago
Hi @thomasbueck
Glide APIs like GlideDateTime, GlideRecord, Will not work inside eval javascript
Please refer this below KB to learn more about the Eval Scripts in patterns
https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0647736
https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0597728
Output:
Type EVAL( and Click on Pencil Icon to write the code!
var timestamp = '1715146200000';
var dt = new Date(parseInt(timestamp));
var output =
dt.getFullYear() + '-' +
('0' + (dt.getMonth()+1)).slice(-2) + '-' +
('0' + dt.getDate()).slice(-2) + ' ' +
('0' + dt.getHours()).slice(-2) + ':' +
('0' + dt.getMinutes()).slice(-2) + ':' +
('0' + dt.getSeconds()).slice(-2);
output;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
share your script here
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
That's the script:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago - last edited 3 weeks ago
Hi @thomasbueck
Glide APIs like GlideDateTime, GlideRecord, Will not work inside eval javascript
Please refer this below KB to learn more about the Eval Scripts in patterns
https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0647736
https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0597728
Output:
Type EVAL( and Click on Pencil Icon to write the code!
var timestamp = '1715146200000';
var dt = new Date(parseInt(timestamp));
var output =
dt.getFullYear() + '-' +
('0' + (dt.getMonth()+1)).slice(-2) + '-' +
('0' + dt.getDate()).slice(-2) + ' ' +
('0' + dt.getHours()).slice(-2) + ':' +
('0' + dt.getMinutes()).slice(-2) + ':' +
('0' + dt.getSeconds()).slice(-2);
output;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
@SK Chand Basha Thanks for confirmation - I assumed it, but it's nowhere really clearly outlined.
I'll test your solution next time, as for now I have created a pre processing script and this worked as well.
Thanks again I appreciate your effort and willing to help.