Thursday, September 22, 2011

SharePoint Workflow Alerts based on Days

 Creating SharePoint Workflow Alerts based on Days

Define: Automatically start when a new item is created
Workflow Steps:

Step 1: Set dates
Conditions: none
Run all actions in parallel
Actions: Add -60 days to Current Item:ExpDate (Output to Variable:60-day)
and Add -30 days to Current Item:ExpDate (Output to Variable:30-day)
and Add -10 days to Current Item:ExpDate (Output to Variable:10-day)

Step 2: ExpDate > Today + 60
Conditions: If Variable:60-day is greater than Today
Actions: Pause until Variable:60-day
then Add -60 days to Current Item:ExpDate (Output to Variable:60-day)

Step 3: 60 days notice
Conditions: If Variable:60-day is less than or equal to Today
and Variable:30-day is greater than Today
Actions: Send email
then Pause until Variable:30-day
then Add -30 days to Current Item:ExpDate (Output to Variable:30-day)
then Add -10 days to Current Item:ExpDate (Output to Variable:10-day)

Step 4: 30 days notice
Conditions: If Variable:30-day is less than or equal to Today
and Variable:10-day is greater than Today
Actions: Send email
then Pause until Variable:10-day
then Add -10 days to Current Item:ExpDate (Output to Variable:10-day)

Step 5: 10 days notice
Conditions: If Variable:10-day is less than or equal to Today
and Current Item:ExpDate is greater than Today
Actions: Send email
then Pause until Current Item:ExpDate

Step 6: Expiration notice
Conditions: If Current Item:ExpDate is less than or equal to Today
Actions: Send email




One thing that might make the whole process less confusing is to create a Variable:Orig ExpDate as the first step in both workflows. Then add to each of the Conditions (after the first Pause): "and Current Item:ExpDate = Variable:Orig ExpDate"

That will make sure you only have the workflow running which was triggered by the most recent change/create.
Conditions: If Current Item:ExpDate not equals Variable:Orig ExpDate
Actions: Stop workflow (Log "Expiration Date has been changed.")


Here are the results from my test:
1. Testing with long ExpDate ExpDate: 12/29/2011 Status: In Progress (No email rec'd yet)
2. ExpDate = Today + 60 ExpDate: 2/27/2011 Status: In Progress (Rec'd 60 day email)
3. ExpDate = Today + 61 ExpDate: 2/28/2011 Status: In Progress (No email rec'd yet; Changed to Today + 365: ExpDate: 12/29/2011, so I don't expect to get a notice tomorrow either)
4. ExpDate = Today + 30 ExpDate: 1/28/2011 Status: In Progress (Rec'd 30 day email)
5. ExpDate = Today + 31 ExpDate: 1/29/2011 Status: In Progress (Rec'd 60 day email)
6. ExpDate = Today + 10 ExpDate: 1/8/2011 Status: In Progress (Rec'd 10 day email)
7. ExpDate = Today + 11 ExpDate: 1/9/2011 Status: In Progress (Rec'd 30 day email)
8. ExpDate = Today ExpDate: 12/29/2010 Status: Completed (Rec'd Exp email)
9. ExpDate = Tomorrow ExpDate: 12/30/2010 Status: In Progress (Rec'd 10 day email)
10. ExpDate = Yesterday ExpDate: 12/28/2010 Status: Completed (Rec'd Exp email)


No comments:

Post a Comment