cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
vaishalivyas1
Helper III
Helper III

count no of files in a particular SharePoint folder and update in dynamics

Hi All,

 

I am creating flow with below fucntionality.

1. Whenever record is created in MS CRM create some folder structure in SharePoint. 

2. Count no of files in each folder and update that number in MS CRM.

 

Example: On Create of Account create "Contact" and "Related Document" folders in SharePoint and count files in each folder and update in "Contact count" and "Realted Document Count" fields in Dynamics respectivly.

 

I completed point 1 succesuuflly but I am not able to count no of files in each folder in SharePoint.

 

How can we add filter query on  "Get item" to retrieve and count no of files in that particular  folder

Below is the screen Capture: 1.png2.png

1 ACCEPTED SOLUTION

Accepted Solutions
Willemijn
Resolver III
Resolver III

Hi, 

 

If you only want to count the files in the specific folder you can maybe use the action 'Send an HTTP request to SharePoint':
image.png

 

As Uri: /_api/web/getfolderbyserverrelativeurl('/sites/testflow/LibraryTitle/foldername')/ItemCount

As a result you get the items in this specific folder. 

 

Hope this helps! Otherwise let me know 🙂

Willemijn

View solution in original post

4 REPLIES 4
Willemijn
Resolver III
Resolver III

Hi, 

 

If you only want to count the files in the specific folder you can maybe use the action 'Send an HTTP request to SharePoint':
image.png

 

As Uri: /_api/web/getfolderbyserverrelativeurl('/sites/testflow/LibraryTitle/foldername')/ItemCount

As a result you get the items in this specific folder. 

 

Hope this helps! Otherwise let me know 🙂

Willemijn

Hi @Willemijn 

 

Thanks for the solution, which works well. Any idea how to assign the ItemCount to an integer variable? I'm trying to work with the output of the GET request, which looks like this:

{
  "d": {
    "ItemCount": 5
  }
}

 

Struggling to extract the number and use it as a variable though. Any suggestions? Thanks

Hi! 

 

You could use the Parse Json action for that, use the body of your request as value, and use sample load to generate the schema.

After that action you can use 'Itemcount' as a dynamic value. 

 

Thanks @Willemijn ,

 

That did the trick, and now I know what Parse JSON does 👍

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Users online (3,840)