February 2017 Mission: Real World Solution

Document created by cazza162 Moderator on Feb 9, 2017
Version 1Show Document
  • View in full screen mode

OK so considering this was a mission I created I thought I best document my approach...  I am amazed already by all the different approaches!  This was a real life requirement in my business and I thought it would be a good simple(ish) solution to put you all to work for your points

 

First things first, we are in February and the whole of 2017 needed to be populated in the calendar.  I had this in mind when I designed the solution.  Here goes, let me try and explain my approach:

 

Patching Schedule List

I thought this would be a good way of future-proofing the solution.  He only wanted six servers, but what if one day he wanted another server adding - I wouldn't want to have to edit the workflow again!  So I created a custom list with the title field renamed to Server and a numeric field to capture the number of days after patching Tuesday for the date of the server patching.

 

Site Workflow

I decided to approach this solution with a site workflow.  The site workflow did the following steps:

  1. Created a date variable called vDateStartDate, default value today's date, show on start form
  2. Build string to find the day of the week (i.e. Monday, Tuesday etc) of the variable vDateStartDate and store in vTextCurrentDay
  3. Log in History list the values of vDateStartDate and vTextCurrentDate
  4. Switch action to evaluate vTextCurrentDay as pictured.  The logic here was that this would always be the 1st of the month (vDateStartDate) - will come on to this later - so if the 1st day of the month was a Monday, then 8 days later would be the second Tuesday of the month etc.  So the 2nd Tuesday of the month "Patching Tuesday" is stored in vDate2ndTuesday.
  5. Query the list Patching Schedule to pull back all the IDs of the items into a collection
  6. For each item in the collection, re-query the list to get the server name and days afters patching Tuesday
  7. Still in my for each loop I calculate the date required for the server using the vDate2ndTuesday and the number of days after patching Tuesday returned from the list
  8. Still inside my for each loop I then log the details to the history list and add an item to the calendar for the item in the collection.

 

So now to populate the calendar for all of 2017...

I run the site workflow manually and pass the start date variable 01/01/2017.

I run the site workflow manually and pass the start date variable 01/02/2017.

I schedule my site workflow to run on the 01/03/2017 and repeat monthly until 02/12/2017.

 

And here you have it!

2 people found this helpful

Attachments

    Outcomes