For each loop not returning collection ID's

  • 4 November 2019
  • 2 replies
  • 7 views

Badge +1

Hello,

 

I am having trouble pulling collection ID's in a for each loop. Scenario:

 

Applying this to a site workflow.

 

I have overdue tasks that need to be emailed to users in individual emails. Now, I have managed to pull the entire table to highlight overdue tasks but I can only manage to collect that into one email and HTML table for a notification. 

 

I am looking to send multiple individual email notification to the assignee with their respective tasks that are overdue. 

 

I have made a query to pull individual assignees that have 1 or more overdue tasks. When I put this collection into a for each loop and try to query the collection of ids for these tasks it simply comes up blank?

 

Is this possible, please!?

 

 

 


2 replies

Badge +12

@sumalh ....You will have to query your task list twice. Try below approach:

 

  • Query your task list and get Assignee collection
  • Now for each assignee, query again your task list and filter where the assignee is "each_Assignee_WF_Variable", Status is not started and also filter based on a date parameter (to decide it's overdue). This time you get the ID collection
  • Now for each each ID, you can use build string to build your HTML code
  • Send that in email notification, make sure it's Rich text and not plain text
Badge +1

Thanks for the reply - I have got to this stage already. My problem occurs with the next step.

 

I have multiple Id's assigned to the assignees. Instead of one bulk email going out to all I was looking at a for each loop to capture the multiple id's for each assignee and email out the details. It's not ideal every one knowing each analyst overdue tasks via bulk email. So the idea is to only email the assignees direct with there task that is overdue and then for each loop onto the next. 

 

Hopefully, the below helps layout my dilemma:

ID Analyst Overdue?
1 Bob yes
2 Bob yes
3 Harry yes
4 Pete no
5 Harry yes
6 John no 
7 Collin yes
Query below complete to capture overdue Id's    
Overdue ID's Analyst Overdue?
1 Bob yes
2 Bob yes
3 Harry yes
5 Harry yes
7 Collin yes

 

Next Steps causing roadblocks

1 email needs to go to <Analyst Bob> containing details from Id's 1 &2
1 email needs to go to <Analyst Harry> containing details from Id's 3 &5

1 email needs to go to <Analyst Collin> containing details from Id 7

Reply