I would like to populate a sharepoint list with First Name, Last Name , Email Address of specific groups from AD. I have created a Query Ldap to fetch the data I want and used a FOr Loop action to populate the list. But with For Loop action I can only work on one single collection at a time, how do I handle inserting all 3 columns in a sharepoint list?
Solved! Go to Solution.
You found an interesting scenario where you do not have an ID to match each value in the other collections in order to save each value to the same list item. On top of that, you may have a case where the last name is blank(who knows why), but if you do then there is a mismatch in the counts among the collection and you may never know. So you could not simply iterate through each collection one by one and hope for the best.
I've been in this situation before and the best method I could find is to first get the unique collection and save it's contents to the list. In this case, it would be the email. Then loop through the email collection using a for each. Within the loop with a single email as currentEmail var, QueryLdap on that email and find firstName and LastName and save them in a single line of text variable. Then update the list item using the Update Item setting the filter to the currentEmail as a match and update the two fields firstName and LastName.
The side effect here is the number of queries went up xNumber of people to fetch, but it will get your data as you need it.
Maybe someone has a better way though.