Hello, I am having a little trouble trying to figure this one out. I have a site workflow that I need to cycle through all list items (in a particular list) and capture a few things. I'm using the Query list control to capture the information I need. Inside the list will be birthdays. My goal is to be able to identify any person who has just turned 23. So, what workflow control will allow me to create an age variable from a birthdate? Once I identify someone, send an email to the corresponding person who needs to know the information. I can easily convert age in the form, but unfortunately that doesn't help me here. Someone would need to jump into the forms and update them from time to time. If someone has a way to do this, please let me know. Thanks
What SharePoint version are you on as Inline functions differ if Online?
use calculate date action to calculate a date 23 years ago. store the result as an ISO string
then use query list action to find all the items where birthday equals to calculated date.
note this assumes the workflow will be schedule to run daily. if you will run it with different period, eg. weekly, you have to consider that - you would need then look for birtdays falling in a period of a week. so you will have to calculate two dates like -23years and -23years_and_one_week, and make the query with greater/less then conditions.
This works perfectly. Slight adjustment, I had already collected the information earlier in the query list tool and setup a For Each loop to cycle through the list. After I performed the Calculate Date, I ran a Run If, to see if the dates matched. To answer your question, yes this workflow will be designed to run daily. Now, I've discovered a slight problem. There maybe several documents per person. If I send an email each time I hit the same person's documents, the receiver of the emails may get overloaded with notices. I need to figure out that once a person's has been identified as 23, ignore any subsequent documents.
design it the opposite way, as I suggeted. it will be much more efficient - you will need to deal within workflow with just small(er) subset of items, not the whole list.
and it will make it easier to deal with your problem - once you read in just list of user that are to be notified for their birthday on a given date, (I guess) you do not need them to be related to source items anymore. so you can simply dense collection of user to unique user list with 'remove duplicates' operation of collection action.
then simply run for each over collection and send out single mail per user.
Again you saved me. I was orginally thinking of this overtly complicated double loop to perform this task. Your process was much easier. Here is how I have it setup now. I start with a Calculate Date
Using your suggestion from above. I then query the list to pull in information I'm going to need. The variables I've setup are all collection variables.
I then use a Collection opearation to remove duplicates.
Now I run a For Each loop to cycle through my unduplicated list of people.
The index variable is a number variable.
The collection operation now captures the person's birthday and assigns that to a different variable so I can check to see if the person turned 23.
The other collection operation looks to see which building the person is located.
Last step is a Run if to see if my check date is equal to the person's birth date. If it matches, send an email.
Thank you @emha for your assistance here. I have a few other things I'll need this workflow do, but this was the section I was getting stumped on.
great you came to a solution.
few notes, though ...
since you iterate over a collection where you removed duplicates from, you can not use its loop driving index variable to pick values from other collections. collections do not match anymore.
imagine you'd get returned collection of users like
userA
userA
userB
and collection of respective returned item IDs like
1
2
3
if you remove duplicates from user collection, you will get collection like
userA
userB
so if you're currently on 2nd iteration (userB) and picked a collection element from IDs at index position 2, you get completelly unrelated value.
since the query list action returns ONLY items that match the birthday date, you need not to check it once again with a run if action :)
Reply
Enter your username or e-mail address. We'll send you an e-mail with instructions to reset your password.