Skip navigation
All Places > Getting Started > Blog > Authors M S

Getting Started

2 Posts authored by: M S

These steps provide an alternate method to share a Collection variable across multiple workflows, should the Store/Retrieve method not suit. In this example I have 2 list workflows where Workflow1 creates the Collection variable and Workflow2 continues to use the Collection variable.

 

 

 

STEP 1: In Workflow1 use an Update Item action to copy the Collection variable called varCOLString to a Multi-Line Text column called tString.

 

1.PNG

 

Example: Based on our collection variable the text in our tString column might look like this: 1;2;3;4;5;6;7;8;9;

 

 

STEP 2: In Workflow2 use a Set Variable action to copy the tString column to a Multi-Line Text variable called varMLTString.

 

2.PNG

 

 

STEP 3: Use a Build String action to count the number of characters in varMLTString and store this in a Text variable called varTXTLastChar.

 

3.PNG

 

Text: fn-Length({WorkflowVariable:varMLTString})

 

 

Example: Based on the string 1;2;3;4;5;6;7;8;9; the result in varTXTLastChar will be 18.

 

 

 

STEP 4: Use a Math Operation action to subtract 1 from varTXTLastChar and store this in a Number variable called varNUMCount.

 

4.PNG

 

 

Example: Now the value we carry into varNUMCount is 17.

 

 

 

STEP 5: Use another Build String action to remove the last character from the varMLTString variable using the Remove inline function and varNUMCount as a reference.

 

5.PNG

 

Text: fn-Remove({WorkflowVariable:varMLTString}, {WorkflowVariable:varNUMCount}, 1)

 

 

Example: We've removed one from the character count because the Remove inline function starts at zero. The varMLTString variable now looks like this 1;2;3;4;5;6;7;8;9 (we have removed the trailing ";").

 

 

 

STEP 6: Finally use a Regular Expression action and the Split function to output the values of varMLTString into a new Collection variable called varCOLString.

 

6.PNG

 

 

Example: The string 1;2;3;4;5;6;7;8;9 will be split by the ";" character and each value will be added to the new collection.

Here is one approach to creating a holiday booking workflow that excludes weekends and bank holidays. The logic of this workflow is based on creating a collection variable containing the date range of the requested holiday dates, a collection containing the bank holidays and then checking these dates against each other to filter out the bank holidays. The key to this working is enforcing the date formats throughout the workflow.

 

STEP 1: Create a custom list called HolidayBooking with 2 date columns for DateStart and DateEnd. The end user will use the DateStart and DateEnd to define the duration of their holiday.

 

 

STEP 2: Create a list workflow on the HolidayBooking list with the following variables:

 

3_WorkflowVariables.png

 

 

STEP 3: Create a collection called varColBankHol containing the bank holiday dates. These dates will eventually be excluded from the requested date range.

 

  • Regular Expression:
    • Pattern: ;
    • Operation: Split
    • Input text: [Add bank holiday dates separated with semi-colons ";". Ensure there is no semi-colon at the end of the string as per screenshot below.]
    • Store results in: varColBankHol

 

 

 

Example:

The Bank Holiday collection (varColBankHol) looks like this:

02/05/2016;30/05/2016;29/08/2016;26/12/2016;27/12/2016

 

 

STEP 4: Add the start date and end date as variables.

 

  • Set variable: varDateStart = StartDate
  • Set variable: varDateEnd = EndDate

 

4_SetVariable.PNG

 

 

STEP 5: Create a collection called varColRequestedDates containing the range of requested holiday dates ensuring they are formatted as dd/MM/yyyy. After the loop add the end date to the varColRequestedDates collection.

 

  • Loop: until varDateStart = varDateEnd
  • Collection operation:
    • Target collection: varColRequestedDates
    • Action: Add
    • Value: fn-FormatDate(varDateStart, "dd/MM/yyyy")
  • Calculate date: varDateStart + 1 day
  • Collection operation:
    • Target collection: varColRequestedDates
    • Action: Add
    • Value: fn-FormatDate(varDateEnd, "dd/MM/yyyy")

 

 

7_LoopUntil.PNG

 

 

Example:

The resulting collection (varColRequestedDates) based on a start date of 27th May 2016 and an end date of 2nd June 2016:

27/05/2016;28/05/2016;29/05/2016;30/05/2016;31/05/2016;01/06/2016;02/06/2016;

We next need to filter out the weekends and bank holidays from this range. 28/05/2016 & 29/05/2016 are weekend dates and 30/05/2016 is a bank holiday.

 


STEP 6: Remove weekends from the varColRequestedDates collection of requested dates.

 

  • For each:
    • Target collection: varColRequestedDates
    • Store results in: varDate1
  • Run if:
    • Condition: If any value equals value

Value: fn-FormatDate(varDate1, "dddd")

does not begin with

S

  • Collection operation:
    • Target collection: varColBusDates
    • Action: Add
    • Value: fn-FormatDate(varDate1, "dd/MM/yyyy")

 

 

 

Example:

The resulting collection (varColBusDates) with the weekend dates removed:

27/05/2016;30/05/2016;31/05/2016;01/06/2016;02/06/2016;

We removed 28/05/2016 & 29/05/2016 from the collection.

 

 

STEP 7: Now we have a collection variable containing a range of dates that excludes weekends. We now need to exclude bank holidays.

 

  • For each:
    • Target collection: varColBusDates
    • Store results in: varDate1
    • Stop processing: varYNEndLoop
  • Collection operation:
    • Target collection: varColBankHol
    • Action: Exists
    • Value: fn-FormatDate(varDate1, "dd/MM/yyyy")
    • Store results in: varYNExists
  • Run if:
    • Condition: If any value equals value

Workflow Data: varYNExists

equals

Value: Yes

  • Collection operation:
    • Target collection: varColBusDates
    • Action: Remove by value
    • Value: fn-FormatDate(varDate1, "dd/MM/yyyy")
  • Run if:
    • Condition: If any value equals value

Value: fn-FormatDate(varDate1, "dd/MM/yyyy")

equals

Value: fn-FormatDate(varDateEnd, "dd/MM/yyyy")

  • Set variable: varYNEndLoop = Yes

 

8.png

 

 

Example:

The resulting collection (varColBusDates) with the bank holiday dates removed:

27/05/2016;31/05/2016;01/06/2016;02/06/2016;

We removed 30/05/2016 from the collection.

 

 

We now have a collection of dates based on a date range specified by the user that excludes weekends and bank holidays.

 

Mitch

Filter Blog

By date: By tag: