Skip to main content
Nintex Community Menu Bar
Solved

Loop for each


Forum|alt.badge.img+10

Hello,

 

I am trying to break then update permissions for each item in a sharepoint list. I am using a component WF to handle this and only able to update successfully if I specifically state in the condition that “ID equals 12345”, but I need it to iterate though out the entire list and update each item.

 

 

Best answer by Prineel_V3

@jpacheco if you are trying to loop through every item in your SP list, you do not need any conditions in the “Query a list” action. It will automatically query all the items. However, i see that you are filtering based on the status. So instead of looping through everything and then filtering out the items you want to update permissions on, put those conditions in your “query a list” action. It will return only those items where the condition is met. Then you can loop through all the items from the query’s object and update the permissions using the variables from the first message.

This is what your query a list should look like (feel free to max the item limit if you have a large list):
 

In the Update Permissions action, your ID and Created by variable, comes from the loop for each tab:

So basically the logic is, for every item (where the statuses match the condition) to have the user who created that item, have read only access. If you use the “First Item> Created by” variable, from the SharePoint Online Object, that will only give the first item’s user, in the collection, “Read Only” permissions to all of the items in the collection (I hope that makes sense). Let me know if you need a better explanation.

 

View original
Translate
Did this topic help you find an answer to your question?

Forum|alt.badge.img+8
  • Nintex Employee
  • January 9, 2025

Hi ​@jpacheco 

If you are looping through the Items Collection variable from your object/query, in the loop for each tab, you can use the current item’s ID variable:
 

If you are looping through the Item ID(s) collection variable from your query, you need to use the current item variable in the loop for each section:
 

To get these variables, simply press insert on the condition builder in the Update Item Permissions action:

 

Translate

Forum|alt.badge.img+10
  • Scout
  • January 9, 2025

@Prineel_V3 ,

 

Thanks for the quick response! 😁

 

So please excuse my ignorance but not sure how to apply your recommendation…

What I am trying to do is look (loop) at every name listed under the Created By column and apply it with the “Update item Permission” control on the last screen shot.

 

So currently I have:

 

Translate

Forum|alt.badge.img+8
  • Nintex Employee
  • January 9, 2025

@jpacheco if you are trying to loop through every item in your SP list, you do not need any conditions in the “Query a list” action. It will automatically query all the items. However, i see that you are filtering based on the status. So instead of looping through everything and then filtering out the items you want to update permissions on, put those conditions in your “query a list” action. It will return only those items where the condition is met. Then you can loop through all the items from the query’s object and update the permissions using the variables from the first message.

This is what your query a list should look like (feel free to max the item limit if you have a large list):
 

In the Update Permissions action, your ID and Created by variable, comes from the loop for each tab:

So basically the logic is, for every item (where the statuses match the condition) to have the user who created that item, have read only access. If you use the “First Item> Created by” variable, from the SharePoint Online Object, that will only give the first item’s user, in the collection, “Read Only” permissions to all of the items in the collection (I hope that makes sense). Let me know if you need a better explanation.

 

Translate

MillaZ
Nintex Employee
Forum|alt.badge.img+21
  • Nintex Employee
  • January 13, 2025

Hi ​@jpacheco 
Has Prineel’s response help answer your question? 

Translate

Forum|alt.badge.img+10
  • Scout
  • January 13, 2025

@Prineel_V3 ,

 

Thanks again for your response, those last examples helped a lot! Sorry couldn’t respond earlier, got caught up.😁👍🏽

Translate

Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie Settings