Can I set the current time as the default input value for a subflow?

bonsai
Mega Sage

 

 

I want to set a datetime type as an input for a subflow.
I want to set the current time as this value, but it's not working...
Does anyone know a good way to do this?

bonsai_0-1757031282171.png

 

1 ACCEPTED SOLUTION

Chavan AP
Tera Guru

 

Refer below image:

If you want to get date/time as current date ,use script type as per below and set default value as javascript: new GlideDateTime(). i have just tested this, its working 

 

Screenshot 2025-09-05 at 04.42.43.png

Chavan AP
[ Architect | Certified Professional]

Was this response helpful? If so, please mark it as Helpful and Accept as Solution to help others find answers.

View solution in original post

6 REPLIES 6

Chavan AP
Tera Guru

 

Refer below image:

If you want to get date/time as current date ,use script type as per below and set default value as javascript: new GlideDateTime(). i have just tested this, its working 

 

Screenshot 2025-09-05 at 04.42.43.png

Chavan AP
[ Architect | Certified Professional]

Was this response helpful? If so, please mark it as Helpful and Accept as Solution to help others find answers.

@bonsai 

Glad I could help! If this solved your issue, please mark it as ✅ Helpful and ✅ Accept as Solution so others can benefit too.
Chavan A.P. Technical Architect | Certified Professional
Chavan AP
[ Architect | Certified Professional]

Was this response helpful? If so, please mark it as Helpful and Accept as Solution to help others find answers.

Ankur Bawiskar
Tera Patron
Tera Patron

@bonsai 

if you want current date/time then why to have that as input.

You can use Flow Variable in subflow and store current date/time and then use it

Another approach you can try is what @Chavan AP mentioned.

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

RaghavSh
Kilo Patron

@bonsai You can store the current time in flow variable and pass that as input to your subflow. 

new GlideDateTime(); will give you current date time.

 

But if I understand correctly, you dnt really need to pass current time as input because that will be the time when subflow will start executing so instead of passing it as input you can easily get date time in subflow itself in your subflow script.

 

In subflow script or variable also you will get it using new GlideDateTime();


Raghav
MVP 2023