Query Multiple Libraries to get files based on metadata


Badge +4

Hi, i have 10 libraries to query and get files with status -ready to move and copy these files to 2nd lib. so far i have done queering one lib, filter based on status and copy the files to 2nd lib. 

Any help is appreciated !


25 replies

Userlevel 5
Badge +14

there's no an action that would query multiple targets at the same time.

your best option is to populate library names/GUIDs into a collection, then iterate over the collection with for each loop action, and within the loop perform all the actions you have already in place for single action.

if the single libraries are from different sites, you might need one additional collection that will store site URLs for each library.

note that you will have build whole CAML query on your own with 'CAML editor' option. CAML builder doesn't list libraries from other site(s) not it allows to supply library name from variable.

216691_pastedImage_1.png

Badge +3

This is similar approach explained in the https://community.nintex.com/message/80593-re-move-doc-from-subfolder-of-one-lib-to-another-lin?commentID=80999#comment-… 

Badge +3

You can also first, complete building the query for one of the list using Query builder and then click on CAML editor for one library. Later make the ListID and Site URL as workflow variables displayed in the snapshot.

Badge +4

HI Marian, 

I have multiple libraries within same site. 

Userlevel 5
Badge +14

so then it's quite simple, isn't it? you need only one collection  happy.png

my above  hint is still valid, it's just simplified  so that you can hard-code 'Site URL'

Badge +4

Thank You Marian and Avinash for your help!

I have set variable action and used list look up--> source as 1 lib earlier, now that i am able to loop through all lib's how does the source read through all lib's ? and how do i update the column in multiple libraries with value from variable ?

Basically I am capturing the url of item in column A in lib 1 and copying the value from colum A (lib 1) to Column A in ib 2. I have assigned embedded ur to varsouceurl variable  and updating column A with varsouceurl; moving the item to lib2 and updating Column A in lib2 with value in Column A in lib 1.   How to choose varGUID's instead 1 Source Documents lib ?

Userlevel 5
Badge +14

I'm not quite sure from your description what exactly you're doing. try to provide more details and some screenshot how does your design look like.

however I've a feeling that you didn't get the point what I tried to depict in above post and you're going into some wrong direction.

this is how IMHO design of your workflow should look like

216771_pastedImage_1.png

Userlevel 5
Badge +14

that shouldn't be a problem, item/dokument URL would one of columns that you need to query for with Query list action as I mentioned above.

Badge +4

Thank You Marian. I got the result. 

Badge +4

HI Marian, 

Thank you for your help! I have everything running except the column update. Say i have column "ColD" which needs to be update by source url. 

I called coll var- "varsourceurlcoll" and assigned to Encoded Absolute url. The urls that i get here- should be updated in ColD for each item in lib1 and lib 2. 

 then query lib 1, 2 - for  ColD collection values,  copy these items to lib 3. 

ColA, ColB values i am able to pull and create in lib 3. ColD i am not able to assign/update the colD in lib1, 2. 

Thank you for your help!

Badge +4

Hi,

I have almost 40 lib's. i have master list whic has list names and Guid. query the master list GUID collection and stored in variable. followed the steps you provide from there. When i run it the files are copied but i have duplicates. say libA has 3 items and 2 with status upload- the two items are copied but in destination lib file is overwritten (test file with test 2(date-number))

Lib A:

Destination lib :

Userlevel 5
Badge +14

how does update action look like?

what datatype of colD column?

Userlevel 5
Badge +14

do you mean that libA/test (ID=22) is copied to DestLib/test2(2018-06....) (ID=667) - ie.the content is the same but name changed

or  libA/test2 (ID=21) is copied (twice) to both DestLib/test2 (ID=666) and DestLib/test2(2018-06....) (ID=667) and libA/test is not copied at all?

looks like you do not correctly work with index variable to get values from collections.

Badge +4

It is copying ID 21 twice. 

Badge +4

Update : I have something like this:

Query  Lib testA

Filter - Status - Ready to Move

Fld - Id =Id Collection

Encoded url - varSourceURL

 

For each - Id collection; Store in Item ID List ID variable.

               1.  Set variable :

         varSourceURL = List Look up

Source - testA lib

Field- Encoded url

When ID =workflow data - Item ID

2. Update testA lib

    1. ID = workflow Data- Item ID
    2. Fld - ColD  = WorkflowData - varSourceURL.

This is for 1 lib, I want ColD to be updated on multiple lib's.

Userlevel 5
Badge +14

this seems suspicious to me...

216818_pastedImage_1.png

what's datatype of varSourceURL?

it should have been a collection....

if it is, it could not be used that direct way in update action.

if it is not, and it is some simple text variable then it gets populated with query list action just with first returned value (related to first returned ID)

btw, why do you query for EndcodedURL for second time from sharepoint when you already have it read in in a collection?

getting it from collection will be much more efficient/faster...

Badge +4
Hi,
I have created master List "List GUID" has columns -   List Names = Names of all lib's ,  GUID column which has GUIDs of Library 
Following is workflow I have written : 
  1. Query " LIST GUID"
 field GUID - GUID Coll   
  1. For each GUID Coll- Store in      single line of text " Unique GUID"
Within for each:   
  1. Query
<Query>    <Lists>      <List ID="{WorkflowVariable:Unique GUID}" />    </Lists>    <ViewFields>      <FieldRef Name="ID" />        <FieldRef Name="ParentFolderURL" />      <FieldRef Name="LinkFilenameNoMenu" />      </ViewFields>    <Where>      <Eq>        <FieldRef Name="Status"  />        <Value Type="Choice">Ready to Upload</Value>      </Eq>    </Where>    <ViewAttributes Scope="Recursive" />  </Query>        ID - ID coll  Parentfolderurl :url coll  File Name - filename coll   
  1. For Each ID Coll - store in      (List Item ID )Item ID ; index :ID Index (number)
Within For each:
  1. Run Parallel:
    1.  
    2. Get Url coll ;       index :urlindex store in varflrurl(single line)
    1.  
    2. Get filename       coll: Index:flname index; Store in :varflname
  1. Create  in lib2 :
    1.  
    2. Name (required       fld) - workflow data - varflname 
    3. ParentFolderURL - workflow       data - varflrurl
not sure where it went wrong and why the items are copied twice
Badge +4

HI Marian, 

The update action is working fine for 1 lib. My question is it possible to add update action in actual workflow: Why I am capturing Url in COlumn is because when the file is rejected from test 2 lib - the file should route back to ColD url. 

Also, Without update action following is the workflow that i have as per your suggestion and the same files are copied multiple times. 

I have created master List "List GUID" has columns -   List Names = Names of all lib's ,  GUID column which has GUIDs of Library 
Following is workflow I have written : 
  1. Query " LIST GUID"
 field GUID - GUID Coll   
  1. For each GUID Coll- Store in      single line of text " Unique GUID"
Within for each:   
  1. Query
<Query>    <Lists>      <List ID="{WorkflowVariable:Unique GUID}" />    </Lists>    <ViewFields>      <FieldRef Name="ID" />        <FieldRef Name="ParentFolderURL" />      <FieldRef Name="LinkFilenameNoMenu" />      </ViewFields>    <Where>      <Eq>        <FieldRef Name="Status"  />        <Value Type="Choice">Ready to Upload</Value>      </Eq>    </Where>    <ViewAttributes Scope="Recursive" />  </Query>        ID - ID coll  Parentfolderurl :url coll  File Name - filename coll   
  1. For Each ID Coll - store in      (List Item ID )Item ID ; index :ID Index (number)
Within For each:
  1. Run Parallel:
    1.  
    2. Get Url coll ;       index :urlindex store in varflrurl(single line)
    1.  
    2. Get filename       coll: Index:flname index; Store in :varflname
  1. Create  in lib2 :
    1.  
    2. Name (required       fld) - workflow data - varflname 
    3. ParentFolderURL - workflow       data - varflrurl
Userlevel 5
Badge +14

could you rather post some screenshots of your configuration then trying it to rewrite? 

it would be much clearer for us to understand and much easier for you to post.

as well, if you post longer code or XML snippet, please use syntax highlighter feature that make text much clearer and easier to read.

216820_pastedImage_1.png

to the point:

where do you populate index variables "urlindex" and "flname index"?

from the enclosing loop action configuration I'd say there should have been used "ID Index" variable in both get collection actions in place of above mentioned index variables.

Badge +4

Userlevel 5
Badge +14

can you provide configuration of each action as well? 

Badge +4

Hi Marian,

if if you see the bottom text that’s the configuration of each actions. 

Userlevel 5
Badge +14

screenshot still would be better. I still have some doubts about your settings.

what eg. purpose of 2nd action (collection operation)? description seems to be just the same as subsequent for each loop action. if it really does what in its description then it makes no sense since index variable is not populated yet, and variables populated with the action are (likely) anyway overwritten by loop action 

looking at the description I'd say it should work.

if it doesn't then check whether real settings match the description. as well check variables definitions, especially those which should be collections.

you may write variables into history log to see what are actual values passed into create item action.

Badge +4

HI Marian, 

The workflow is working appropriately as per your suggestion. I passed wrong coll. 

But how do i  delete the item from lib 1 after creating it in lib 2.  I am quering the master list and collecting GUID's and stored in variable . For each GUID i want the item to disappear from lib1 after its created in lib2. 

Thank you for your help!

Userlevel 5
Badge +14
I passed wrong coll. 

that's why I asked for screenshots. other pair of eyes usually spot different things 

But how do i  delete the item from lib 1

there is a Delete item action (or Delete multiple items once)

https://help.nintex.com/en-US/nintex2013/help/#Workflow/RootCategory/Actions/Nintex.Workflow.DeleteItem.htm%3FTocPath%3D… 

Reply