Site workflow to send approvals to each list item owner at the same time


Badge +2

I wanted to create a site workflow that is executed once per day that checks to see if any items need to be reviewed based on a date, then emails the owner of the item for approval.

 

Because the list of items could be long, I didn't want to send out an approval email for each item. So I used a site workflow to run once per day.

 

It was quite tricky get the workflow to send to each owner because it was a 'person' type column, but I managed it.

 

My problem is that because of the above requirements, I'm left with a workflow with the flexi task inside a 'for each' loop. This means that the sending of the second email is dependant on the first person replying.

 

Is there any way to send all the email out at the same time?

 

List to act on:2414i186CE739CB12138F.jpg

Here is my workflow:

 

I run a query list and filter on 'Review date' < today and Lifecycle is not Retired or Superseded. I store the ID and Owner in itemIDCollection and itemOwnerCollection.

 

I count itemIDCollection, store in numCount and run the workflow if numCount > 0.2415i24690E4EC8F5D398.jpg

I then remove the duplicates in itemIDCollection and store in dedupeOwnerCol. I then run a for each:

2417iEA32C2913F2294E5.jpg

And in the for each I get and store the owner ID and email.

2419i41BD78C5B4FF4842.jpg2420i311C24C24D13BFC9.jpg

I query the same list again and filter on the owner (as well as same filter conditions in first query) and save in idsCol.

 

I update the statuses then assign a flexi task to assignee 'dedupeOwnerEmailTxt'.

2421i7E8A868312E515CA.jpg

I then do a few updates based on the outcome.

The whole thing looks like this:

2423i9F7F312F7F59CB4A.jpg

My issue is that I can only get the second flexi task to send after the first has been approved.

 

2424iB69EFD026EEA17B5.jpg

When approved, second email is sent:2425i99C1D5AA204A622D.jpg

How can I send all flexi tasks at the same time?


4 replies

Badge +8

How can I send all flexi tasks at the same time?


Take the task out of the loop. Put it in its own worfklow. Inside the loop, start this new single-task workflow. That way each loop runs its own worflow which is independent of the rest of them.

Badge +2

I added a new workflow to where the flexi task was in the loop and started the new workflow at the flexi task. 

 

How do I get the second workflow to retain the previously stored variables?It errored out because the the assignee is blank.

Badge +8

I save that information to the list in fields not displayed with public views. That way, if I need to, I can manipulate that information. 

 

So say you wanted the assignee, the url, and the created date from the item to be put into the separate workflow task. Save this information to columns named in a way that makes sense to you. For me I would save them as something like subURL, subAssignee, subCreated. 

 

In your second workflow, you reference those columns when putting information like Assignee in the workflow action. 

Badge +2

Thank you! Splitting my workflow up into 2 worked.

 

If it helps others, here's how I did it.

 

  • Query list to get items in scope. Save 'Owner' column values into itemOwnerCollection variable
  • Count number of items in itemOwnerCollection
  • Remove duplicated in itemOwnerCollection and store in dedupeitemOwnerCollection
  • Run if itemOwnerCollection > 0

2491iC2DD4E7352EEDA77.jpg

  • Update multiple items based on filter
  • Run a For Each on dedupeitemOwnerCollection and store in ownerRawTxt
  • Set OwnerIdInteger equal as ownerRawTxt, and click the ... and select User Id (as Integer). Note - the variable has to be of type integer for this option to appear.2492i46D8788B2E37788B.jpg

 

2493i9974881BF1EC9B2B.jpg

 

I created a temp list. It has one column for the IDs in scope from the list I am interested in.

  • I delete all items from this list.
  • I create an item (remember we are in a loop still with the unique Owner IDs)
  • I start the next workflow.

2495i36422D99F860350A.jpg

The second workflow will start for all in scope Owners.

  • I query the temp list and save the result in itemOwnerIDCollection
  • I loop through each itemOwnerIDCollection (there will only ever be one) and save the result in itemOwnerIDTxt
  • I set itemOwnerIDNum from itemOwnerIDTxt to convert the string to numerical variable
  • I query the original list, filtering on Owner = itemOwnerIDTxt, and set as itemHRAOwnerTxt. I need to do this to ultimately associate the ID with the person as known within SharePoint.2496i1A218B0C95EC7524.jpg
  • I then set itemOwnerEmailTxt = itemHRAOwnerTxt, using ... to set to Email Address

2497iD10347AFEC885ACC.jpg

2498iE6ADF3FEF02B654D.jpg

 

Soooo, after all of this I can finally set my flexi task to itemOwnerIDTxt and send out approvals.

 

  • I then query on my list and filter on Owner = itemOwnerIDNum, along wih my other criteria. I save the ID to idCol
  • I do a For Each loop on each id from idCol and use this to update multiple items for each list owner (and my other criteria).

I don't know why I had to do the last loop - the filter on Update Multiple Items wouldn't filter on itemOwnerIDNum.

 

2499iFB21DB2F9F6E9AB0.jpg

Doing it this way ensured the flexi emails are sent out at the same time, and not dependant on waiting for the previous approver to complete their workflow.

 

Aside:

As I'm running this each day, I created another flexi option to called 'No response'. I have set the flexi task to complete after 23 hours with an outcome of 'No response'. I'll see if this works in practice with real users...!

Reply