Skip to main content

Hi,   I have a workflow that is not giving the option to select ‘Current Item’.  I need that to loop.  below is a output from a ‘Query a List’ .  ID’s for records to interrogate I have available coming from SharePoint Online menu item  / a notification email shows each ID I need to hit.  but in the loop I”m only getting a single record even though appears I am hitting my list through all records.But only get the first tested record to send a run if true email based on conditions. 

 

 

 

 

 

The Output →  result is of type file.

Your Output variable needs to be an Object type. You should then see the Current Item option under that Object variable.


Hello @LandsEnd , 

 

From you screen shots, it seems like you selected the collection of Item ID’s (Integers) as the source for the Loop, but you need to select Items (Objects).

 

 


Hi @LandsEnd 
Has these responses solved your question?

 


Basically, not yet but don’t stop helping lol.

Latest.  Following instructions here’s what I’ve done, but w/o success yet.

  1. In my ‘query a list’ action I created a variable of type ‘object’ seen here, and used that as the output for this query a list action. 

.  

  1. Added a ‘Loop for each’ action wanting to point to that ‘Result’ object above as the ‘Target collection’ in the loop for each.
  1. This is where it gets weird.  I’ve selected the options testing and with ‘item ID(s) , ‘items’ and they just notified in send email the first record over again five times, but that is exactly the number of records I expect.  The ‘First item’ option which is an object everything is grayed out looking into the chevron see what I can select.  Only ‘attachments’ shows as insertable, and I don’t have any attachments.  

Here’s overview to date of steps

In my notification emails I see following, can bring out total number and then each correct ID in array format. I get five emails but its not looping thru each record. I need to see those other records in each their own emails.  So how is it I can apparently get correct number of records - and their ids - but yet only the first record repeats in notifications ??? five emails over ??? 

 


And just to add,  I tried to get the loop for each -→ current item -→ which on its own is not giving ‘insert’ and when in that object everything is grayed out except for attachments. I think that’s the sticking point but don’t know how to get around it.  There is no other ‘collection’ in current item.  

 


I should be getting five different notifications from the loop going against a SharePoint list, I get five but they are all from the same fist record in the list that hits conditions in the run if then sends a notification email.  I can’t figure out why I’m getting five emails as expected but they are all from the same ‘first’ record that is tested in the run if.  


Hi @LandsEnd,

Here’s a simplified design to illustrate how Loop for each should be configured based on a list of items retrieved from Sharepoint:

  1. Query a list
    I am storing the output into object - Customer details from SP

    (I’ll log the count of items returned, just for visibility)

  2. Loop for each
    Identify the Collection of data that you need to loop through. Focussing on the possible results from Sharepoint:
    > Number of items returned is an integer - the count of how many items was found. There is nothing to Loop on.
    > Item IDs is the list of IDs of each item. You can Loop for each on the ID collection if you want to only reference the ID, one at a time.
    > Items holds the items retrieved (rows of items) and their relative properties (SP list columns).
    > First item is a quick way access the first item in the returned list and its properties. This is particularly useful if you are only interested in retrieving a single item. There is no need to Loop on this object, as this will only reference 1 entry.

    In your case, you will want to focus on the Items collection:
  3. Once Loop for each is configured (collection inserted into Target collection), you’ll see a new variable category appear - Loop for each. This is an auto-generated output, based on your configuration of the Loop action. This output can only be used within the Loop for each container (i.e. any nested actions).
  4. Use the Loop for each output data in a contained action. In my case I’m using a simple Log to instance details action. You would replace this with a Send an email action.
  5. Log to instance details
    Configure this to use the auto-generated Loop for each output.
    Loop for each will run through all items in the Sharepoint items object, and give you an object of all of the properties of the Current item.
    I will log the Title of each item that is returned, one by one:
  6. Running the workflow
    This is what my instance looks like:


    Where the first Log to instance is how many items was retrieved from SP. Each subsequent Log to instance logs a single Title, one for each item retrieved - 10 executions (which are below the fold so you can’t see all of them in my screenshot).

Hope this helps!
If you require additional assistance, please reach out to the Support team with an export key.


Hi Kate, THANK YOU !!!  You were concise, demonstrative (so prefer screen shots (not just talk/words) and I have my five emails with unique info based on conditions met. SO THANK YOU.  And note to others → go only after the loop for each ‘current item’ and not first item from the SharePoint Online otherwise you’ll only get ‘first record’ only.

Make sure go blue not SP green as seen here, when pulling info out of the loop.

And,  I like very much the ‘Log To Instance’ , finally I can see what is inside the object, that was equally important.  You just have to go into the instance details to see the log.

 

  . 


Reply