journalEntry/Additional Comments date and time format.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-12-2019 08:44 AM
I am displaying "additional comments" on email notifications.
I have the following requirements:
- Hide the user names
- Re-format the date and time to "standard" AM/PM to MM DD YYYY.
So far, I managed to hide the user names by using a regular expression. I also managed to re-format the date and times on other fields(other than additional comments), I just can't figure out how to combine the two (hide & re-format) on additional comments field.
Can anyone point me in the right direction?
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-12-2019 08:12 PM
Hi,
Can you share the script here?
Sample script here to show value in this format
12-13-2019 04:11 AM
var nowDateTime = new GlideDateTime();
var gd1 = new GlideDate();
gd1.setValue(nowDateTime.getDate());
var gt = new GlideTime();
gt.setValue(nowDateTime.getTime());
var str = gd1.getByFormat("MM-dd-yyyy")+" "+gt.getByFormat('hh:mm a');
gs.info(str);
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-13-2019 10:09 AM
Hello Ankur,
Thank you, for your quick response. I think I am getting close to a solution here. The issue is that the times do not match, all the times/dates are similar.
I have posted a picture, the highlighted times are the default ServiceNow time, and the other times are the ones to the left, after updating the scripts. I added a picture of the script below after adding your updates to it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-14-2019 07:32 AM
Hi,
That must be because of the timezone issue; if you see the difference it is exact 5hours
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-14-2019 08:19 AM
Hello Bankur,
How can iterate through all the comments. Right now the code is just posting the same time for all of the comments. I will look for a solution but any assistance will be much appreciated.
Thank you,