cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How to update documents inside a folder - Document Library

Jump to solution

I have a workflow that creates a folder in my document library.  It then copies any attachments from my list and dumps them in this newly created folder.  Then the folder gets updated with the appropriate GROUP designation but I need the documents inside the folder to also get updated with this group designation from my list.

I guess I need to loop through the newly created folder to get the list of documents and then update the GROUP column.  Can someone clue me in as to how to accomplish this?

Labels: (1)
Reply
11 Replies
Workflow Hero

Re: How to update documents inside a folder - Document Library

Jump to solution

You can do this by comparing the path property (FileDirRef) of the documents with the url path of the folder (FileRef). If they are equal, the documents are Inside the folder.

You can use a query list action to get the documents Inside the folder.

Hope this helps

Reply
Workflow Hero

Re: How to update documents inside a folder - Document Library

Jump to solution

From what I see, you have attachments in a list and you are copying the same attachments to a library. I don't know if I am understanding you correctly, but I wouldn't recommend doing this. Why? Because you have the same document in two locations and they may not be updated. So one may not get updated when the other one is. This is not good for Configuration Management. You should never have the same document in two different locations. Also, it is not recommended to use folders in SharePoint. It is better to either use Content Types, create a field or use different document libraries based on that type of document.  So say they are inventory documents - you could either create a document library called 'Inventory', or a content type called

'Inventory' or a lookup with 'Inventory' as a value. This allows you to better utilize the SharePoint features and metadata.

Reply
Not applicable

Re: How to update documents inside a folder - Document Library

Jump to solution

The reason it is in two locations is because I send an email notification to the client with a link to the folder with the pertinent documents from the document library related to the task.  There could also be more than one deliverable for a task so I wasn't about have multiple links in the email notification.


The plan is to have views created so that I can categorize the folders that get created and grant access to users specific to the appropriate views that contain all the documents or deliverable that relate to their business unit.  I did not want to grant them access to the list.  The folders are titled the same as the task name so I thought that may make it easier for a user to search since that metadata is also in the notification email.

I am not concerned with these documents getting updated, they are a one-time thing.

Perhaps having multiple document libraries isn't a bad idea but that means more workflows to separate them.  I guess for archiving purposes this may be a better approach since some libraries may get larger than others. I will look into that.

That being said, do you have any input on the original question?

Reply
Not applicable

Re: How to update documents inside a folder - Document Library

Jump to solution

Is this method using the CAML editor?  If so, I am not familiar with that.

Reply
Workflow Hero

Re: How to update documents inside a folder - Document Library

Jump to solution

No, I don't set my libraries up with folders so I haven't come across this.

Reply
Workflow Hero

Re: How to update documents inside a folder - Document Library

Jump to solution

No, the query list action can be used without writing CAML directly.

Reply
Not applicable

Re: How to update documents inside a folder - Document Library

Jump to solution

I have this same issue.  Do you have an example of what this query looks like?

Reply
Workflow Hero

Re: How to update documents inside a folder - Document Library

Jump to solution

Sorry for the delay.

To get the path of the folder (this method will only work if the folder is not inside another folder), you can use a Query list action and configure it like the following :

  • select the list or library where the folder is
  • set a filter (for example, a filter based on the folder's title) to get the folder
  • in "Field", you can select "URL Path" (which corresponds to the FileRef), click on add and store this in a variable.

To get the documents inside the folder, you can use a Query list action and configure it like the following :

  • select the list or Library where the documents are
  • check the "Recursive" checkbox
  • set the following Filter :
    • URL Path
    • is equal to
    • add the reference to the variable where the folder's path is stored
  • in "Field", select the fields you want to get (for example "ID" if you'd like to get the ID of the documents which are inside the folder)
  • Then, once it's configured switch to "CAML editor" in editor mode (at the top) and edit the following line :

<Where>

<Eq>

<FieldRef Name="FileRef" />

  • By the following :

<Where>

<Eq>

<FieldRef Name="FileDirRef" />

Then, you can save the action and it should work.

Tell if it's not clear enough or if it doesn't work or if you're folder is inside another folder.

Reply
Not applicable

Re: How to update documents inside a folder - Document Library

Jump to solution

Thank you very much, really appreciate the help!

Reply