Flow Designer: use dynamic dates for tasks

Natalie8
Giga Expert

We currently have a flow that runs off a service request, of which we generate a 12 day lead time.

Within the flow, we need tasks to run within this lead time and wondered how to schedule these within flow designer.

i.e. flow creates task which is due 5 days prior 'due date' of requested item.

Does anyone know a way or code I can add into the field within the flow designer to achieve this (use alongside the 'due date' data pill) 

Thanks!

1 ACCEPTED SOLUTION

Chuck Tomasi
Tera Patron

This would require a custom action definition that you can build. It doesn't require much for code, just using GlideDateTime().addDaysLocalTime() to add/subtract whatever values you pass to the function and return a new date/time.

Action Designer | ServiceNow Docs

Sorry, I don't have a quick link to a video where I built a custom action. You might want to search one of our Live Coding Happy Hour videos.

View solution in original post

3 REPLIES 3

Chuck Tomasi
Tera Patron

This would require a custom action definition that you can build. It doesn't require much for code, just using GlideDateTime().addDaysLocalTime() to add/subtract whatever values you pass to the function and return a new date/time.

Action Designer | ServiceNow Docs

Sorry, I don't have a quick link to a video where I built a custom action. You might want to search one of our Live Coding Happy Hour videos.

Thanks Chuck - apologies, I'm new to any form of code, so struggling with the script.

I've created an action with inputs:

delivery date (original date from requested item)
days (to calculate the + or - value i.e. -5)
activity due (to be populated as an output)

Could someone kindly provide me with some guidance on the code please?

 

hey @Natalie8 did you get a code for this if yes please can you provide me please very urgent