How to display the value of date/time in the field?

icelazer
Kilo Expert

Hi,

 

I'm working on Flows and one of the action needed after triggering the conditions is to set the value of these fields. Please see attached. Would like to seek help on what is the script on returning the date/time in the following fields:

 

1. Last Contact Date = today’s date 

2. Next contact date = 5 Business days 

 

Thanks for the help.

 


var today = new GlideDateTime();
var formattedDateTime = today.getDisplayValue();
g_form.setValue('u_last_contact_date',formattedDateTime);
3 ACCEPTED SOLUTIONS

Vaibhav
Mega Guru

Hello @icelazer 

 

you can get dates by below lines adding into the inline scripts for variables:

1. Last contact date:

 

var today = new GlideDateTime();
return today.getDisplayValue();

 

 

2. Next Contact Date:

 

var nextDate = new GlideDateTime();
return nextDate.addDays(5);

 

for your reference see below ss:

 

Screenshot 2023-09-22 at 2.49.08 PM.png

 

Please mark my answer helpful and solution accepted if it serves the purpose..

 

Regards,

Vaibhav

View solution in original post

Try

businessDays.addDaysUTC(5);

return businessDays;

 

Hopefully, this will resolve your query.

View solution in original post

@Vaibhav   never mind it. I already tried this:

var today = new GlideDateTime();
return today.setDisplayValue(null);

View solution in original post

6 REPLIES 6

Vaibhav
Mega Guru

Hello @icelazer 

 

you can get dates by below lines adding into the inline scripts for variables:

1. Last contact date:

 

var today = new GlideDateTime();
return today.getDisplayValue();

 

 

2. Next Contact Date:

 

var nextDate = new GlideDateTime();
return nextDate.addDays(5);

 

for your reference see below ss:

 

Screenshot 2023-09-22 at 2.49.08 PM.png

 

Please mark my answer helpful and solution accepted if it serves the purpose..

 

Regards,

Vaibhav

Thank you @Vaibhav  . However the script for number 2 is not working on my end. 

I also tried this:

 

var today = new GlideDateTime();
return today.addDays(5).getDisplayValue();

Try

businessDays.addDaysUTC(5);

return businessDays;

 

Hopefully, this will resolve your query.

Hi @Vaibhav   yes it works! Thank you!