Change Date in Flow Designer to a specific day of the week?

Travis Michigan
Mega Sage

I have a request that I think should be possible, but I'm having trouble trying to figure out how to accomplish it in the Flow Designer and was wondering if anyone had an idea on this.

 

What I have is a group that wants tickets submitted for them to take a look at the person's start date, and set the due date of the ticket to the next Thursday after their start date.  I couldn't quite see how to do this.  The only thing I accomplished was I took the date, and added 3 days since the most common start date was going to be a Monday.  

TravisMelvin_0-1678405900939.png


I think there should be a better way to accomplish this, but I suspect I'm missing something, perhaps someone can point me in the right direction?

 

Thank you in advance for any and all suggestions.

1 ACCEPTED SOLUTION

Nootan Bhat
Kilo Sage

Hi @Travis Michigan,

You can use the script to get the next Thursday instead of inbuilt functions.

NootanBhat_0-1678426908843.png

Below is the code:

var currentDate = new GlideDateTime(fd_data.trigger.current.due_date); // here pass the date from which you want to calculate next thursday
var time = currentDate.getTime();
var a1=currentDate.getDayOfWeekUTC();
var delta = 4;
if(a1 == 7){
    delta=11;
}
currentDate.addDaysUTC(7-a1+delta);
var newD = new GlideDateTime(currentDate.getDate());
newD.add(time);
return newD.getDisplayValue();

 

This will give you next thursday.

 

I hope it will answer your query.

 

Thanks,

View solution in original post

3 REPLIES 3

Nootan Bhat
Kilo Sage

Hi @Travis Michigan,

You can use the script to get the next Thursday instead of inbuilt functions.

NootanBhat_0-1678426908843.png

Below is the code:

var currentDate = new GlideDateTime(fd_data.trigger.current.due_date); // here pass the date from which you want to calculate next thursday
var time = currentDate.getTime();
var a1=currentDate.getDayOfWeekUTC();
var delta = 4;
if(a1 == 7){
    delta=11;
}
currentDate.addDaysUTC(7-a1+delta);
var newD = new GlideDateTime(currentDate.getDate());
newD.add(time);
return newD.getDisplayValue();

 

This will give you next thursday.

 

I hope it will answer your query.

 

Thanks,

Hi Nootan Bhat,

 

In my flow design i have planned start date and end date only  i need to display only Monday date in that week 

  • Planned Start Date = Same week as the Planned Start Date on Monday at 8 hr
  • Planned End Date = Same week as the Planned End Date on Monday, at 18 hr

how to do please can you help me

Thank you,

basine

Hi @Travis Michigan,

 

 current.due_due_date  in flow design it won't work it will through error for current , so you have to use instead of current  like example below 

fd_date._1_getcatalog_variables.due_date

 

Thanks & Regards,

Bandi