journalEntry/Additional Comments date and time format.

Maxwell3
Kilo Guru

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?

6 REPLIES 6

Ankur Bawiskar
Tera Patron
Tera Patron

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

 

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

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.

find_real_file.png

find_real_file.png

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

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

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,