Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I'd like to set the value of "Due Date" on "Create Custom Task" within my workflow.

However, I want it to be "weekend aware"...i.e. (Sunday-Thursday working week)
if you create a task on Sunday to Tuesday then its due 2 days later
if you create a task on a Wednesday then its due Sunday
if you create a task on a Thursday then its due Monday

I have looked at workflow variables, but these don't have calculations.
I have looked at "Do Calculatation" but this is very restricted to "add a fixed number"

[Yet again, a simple task in SharePoint proves to be difficult]

share|improve this question

3 Answers 3

up vote 1 down vote accepted

It's not as simple as one could wish, but you can do it by using the following actions as building blocks:

  • Use Find Interval Between Dates to get the number of days from a know date to the create date
  • Use Do Calculation (mod 7) to get the week day of the create date
  • Use a series of if any value equals value togetter with Add Time to Date to calculate the due date
share|improve this answer
    
Wow! Marked answer as correct...but there is no way I will actually build this! I can't beleive how poor a product SharePoint is!...Well played whoever sold it to my company - puppy springs to mind :( –  BlueChippy Nov 6 '12 at 4:16

It's rather a late reply, but as a search for this still led me here 10 months later, I thought I'd give a code example of Per Jackson's response above in SPD 2013 (I haven't got an earlier version to test with I'm afraid). In my example of an IT HelpDesk, the DueDate value gets set based on the priority of the ticket raised, then changes the DueDate value if it falls on a Saturday or Sunday (to Monday or Tuesday respectively):

Step: 3 - Set "Due Date" based on Priority 
    Step: 3.1 Set initial value for DueDate
        If Current Item:Priority equals (1) High
            Add 0 months, 0 days, 11 hours, 0 minutes to Today (Output to Variable: DueDate )
        If Current Item:Priority equals (2) Normal
            Add 0 months, 2 days, 11 hours, 0 minutes to Today (Output to Variable: DueDate )
        If Current Item:Priority equals (3) Low
            Add 0 months, 5 days, 11 hours, 0 minutes to Today (Output to Variable: DueDate )
    Step: 3.2 Fix DueDate for weekend values
        Set time as 0 : 0 for Variable: DueDate (Output to Variable: DueDate )
        Find days between 01/07/2013 00:00:00 and Variable: DueDate (Output to Variable: DaysBetweenMondayAndDueDate )
        Calculate Variable: DaysBetweenMondayAndDueDate mod 7 (Output to Variable: Mod7DueDate )
        If Variable: Mod7DueDate is greater than or equal to 5
            Add 0 months, 2 days, 0 hours, 0 minutes to Variable: DueDate (Output to Variable: DueDate )

Set time as 17 : 0 for Variable: DueDate (Output to Variable: DueDate )
    Update item in Current Item
    Log Due date set to [%Current Item:Due Da... to the workflow history list

Step 3.1 decides that 'If a call is logged in the afternoon, it doesn't need to be resolved until tomorrow', then sets a Date/Time variable called DueDate.

Step 3.2 sets the Time part of DueDate to 00:00 to avoid decimals in later calculations.
It then uses the "Find days between" function to find the number of days between a Monday (01/07/13 in this case, but it could be any Monday - and it's in DD/MM/YY format here due to my localisation settings). This value is then stored in a Number variable called DaysBetweenMondayAndDueDate.
It then uses the "Calculate" function to do (DaysBetweenMondayAndDueDate Mod 7), which gives us a nice round number between 0-6 where 0 represents a Monday (as that's what 01/07/13, used earlier, is and 6 represents a Sunday. This is stored as another Number variable called Mod7DueDate.
Finally, if Mod7DueDate is greater or equal to 5 (i.e. if it falls on a Saturday or Sunday), add two days to the original DueDate variable to move it to Monday or Tuesday respectively.

The last functions set the Time part of DueDate to 17.00 (which happens to be my preference in this case), then updates the List item with DueDate variable.

Hope this helps someone :)

share|improve this answer

Without custom code, I can see no way of doing it on with de SPD.

Best regards.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.