cancel
Showing results for 
Search instead for 
Did you mean: 
tmfitz
Nintex Newbie

How can I use the Loop action to find and update items in another list?

Here is the scenario I have:

  1. Documents are uploaded into a document library with an associated ProjectID.
  2. I have a list to track whether or not the required documents are uploaded.  The ProjectID of a document may be listed and associated with multiple items in this list.
  3. Once the workflow matches a ProjectID, it should update those items with Today's Date and a link back to the document.

I thought I would use the Loop action but am having a hard time getting started.

Labels: (1)
0 Kudos
Reply
5 Replies
Automation Master
Automation Master

Re: How can I use the Loop action to find and update items in another list?

Hi Teresa,

The workflow architecture I'd introduce would probably depend on what you would want to launch this process.  Also the process could be slightly different depending on whether you are using on-prem or O365, but in generic/general scenario you will want to:

Use the Query List action to return a collection of items that match your ProjectID for the document.   You can put a filter on this action to specify a specific ProjectID - in this case the one .  For example, if you wanted all items where ProjectID = 100 you could achieve this with this action.

Once the query returns you will have saved the results into a Collection Variable.

Now you are able to use either the Loop Action (or preferably (for me anyways) the For Each action) to loop over this collection.  Inside of the loop, you could then use an Update Item action to make the updates you need to your target list.

Hope that helps a bit.

Mike

0 Kudos
Reply
Not applicable

Re: How can I use the Loop action to find and update items in another list?

Mike,

As an extension of Teresa's question, how might you extend this for the following scenerio...

Requirement: Query a list on a site (source list) and then for each item determine if there is a matching item (by ProjectID) in another list(target list) on a subsite. If a match, then update several fields in the target item from the matching source item, else create a new target item. I assume a similar For Each action on the source list collection.

It appears that because the target list(subsite) is not on the same site as the source list this would require several Call Web Services actions to GetListItems and then to UpdateListItems ("new" or "update"), and would require xml or caml code which I am not familiar with. The GetListItems would have to be done using a "key" (ProjectID) from the collection item.

Am I on the right track with this? Could you possibly provide a sanple workflow, most importantly the code to use within each Call Web Service action.

Thanks much for any info or advice.

Ira

0 Kudos
Reply
Automation Master
Automation Master

Re: How can I use the Loop action to find and update items in another list?

Hi Ira,

You are on the right track for sure!   Here is the SOAP xml that you will need to place inside of the GetListItems webservice. When you are configuring the web service action, click on the SOAP editor radio button and copy and paste the below code in.  Make sure to insert the variable that would be applicable to you where I have it in bold.  With this I'm sure you will be able to figure the rest out.

<?xml version="1.0" encoding="utf-8"?>

<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">

    <soap:Body>

        <GetListItems xmlns="http://schemas.microsoft.com/sharepoint/soap/">

            <listName>Your List Name</listName>

            <viewName></viewName>

            <Query>

                <Where>

                <Eq>

                    <FieldRef Name="ProjectID" />

                    <Value Type="Text">{Insert Your Reference Var or Property Here}</Value>

               </Eq>

               </Where>

            </Query>

        <viewFields></viewFields>

        <rowLimit></rowLimit>

        <QueryOptions></QueryOptions>

            <webID></webID>

        </GetListItems>

    </soap:Body>

</soap:Envelope>

0 Kudos
Reply
Not applicable

Re: How can I use the Loop action to find and update items in another list?

Mike,

I thank you for your response as this is helpful. However, again knowing nothing of xml/soap/caml, etc. I am still left with issues as to how to complete this process.

I am testing my wf in steps to see results and in the step you helped me with, it completed w/o error, so I assume that I should somehow be able to get the specific Item ID that I need to be updated. But what I need from the GetListItem is the value of the ID field so that I can continue by using the UpdateListItem web service (using the retrieved ID) and then updating specific fields that had been retrieved from a source list.

I have tried using this example to work with… https://qwww.honeywellprocess.com/library/support/Public/Documents/Call%20Web%20Service%20eg%20V2.pdf

But there are issues. For example, there is no place to specify using the Result Format “xml” in the web service.

Also, the following code creates an error in the action, so I cannot use it…:

I tested having the Stored Results (variable text field) sent in an email, but it was blank… even though when I viewed the action result in the workflow history, it had data as follows…:

I realize that this is a lot of information to digest, but if you should have the time, is there some way we might be able to work this out together? What other suggestions can you offer?

Thanks so much for your time and consideration,

Ira

0 Kudos
Reply
Not applicable

Re: How can I use the Loop action to find and update items in another list?

Mike,

Regarding my response above, I did get xmlresults 2 times using the example I used, but even though I queried with a specific/unique TitleID, it returned several items. Since, I now receive the following error on the Call Web Service to GetListItems...: "Error returned from server: The underlying connection was closed: An unecpected error occurred on a send." So I am not retrieving the data anymore. Any thoughts or suggestions.Following is my xml from within the Call Web Service action...:

<?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">

<soap:Body>

   <GetListItems xmlns="http://schemas.microsoft.com/sharepoint/soap/">

     <listName>{WorkflowVariable:varTargetListName}</listName>

     <viewName></viewName>

     <query>

         <Query>

             <Where>

                 <Eq>

                     <FieldRef Name="TitleID" />

                     <Value Type="Text">{WorkflowVariable:varTitleID}</Value>

                </Eq>

            </Where>

        </Query>

    </query>

    <viewFields></viewFields>

    <rowLimit></rowLimit>

    <queryOptions xmlnsSmiley FrustratedOAPSDK9= "http://schemas.microsoft.com/sharepoint/soap/" >

  <QueryOptions/>

  </queryOptions>

  <webID></webID>

  </GetListItems>

  </soap:Body>

</soap:Envelope>

Thanks Much,

Ira

0 Kudos
Reply