cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
DesignerMat
Level: Powered On

Filter SubDomain Level

Hi There,

 

I am creating a flow that sends a summary of newly added folders to a SharePoint site. I have done a condition that only pulls if it is a folder. What I am now trying to do is ignore from a certain level of the subfolder. 

 

For example:

 

Pull data from: "/FolderA" or "/FolderA/FolderB"

Ignore: "/FolderA/FolderB/FolderC..."

 

I have tried everything even targeting the "/" to determine folder level.

Screen Shot 2019-05-10 at 11.45.32 AM.png

Thanks for the help in advance

 

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: Filter SubDomain Level

Hi @DesignerMat ,

 

Do you want to get a summary list of certain level of the subfolder?

 

Please check if the following workaround will work for you.

 

Under the action Get files (properties only), add action Filter array to filter out only folders.

 

Then in the action Create HTML table, select Body from Filter array, custom the fields:

Path:

join(take(split(item()?['{Path}'],'/'),2),'/')

An image for your reference.

1.PNG

 

Best regards,

Mabel

 

 

Community Support Team _ Mabel Mao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

14 REPLIES 14
Super User
Super User

Re: Filter SubDomain Level

I'd recommend not using the condition, and instead use the Filter Query option within the Get files action. This allows you more granular control, while also improving the overall performance of your Flow.FilterQuery.png

Here's some further documentation on filtering data: 

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

Community Support Team
Community Support Team

Re: Filter SubDomain Level

Hi @DesignerMat ,

 

Do you want to get a summary list of certain level of the subfolder?

 

Please check if the following workaround will work for you.

 

Under the action Get files (properties only), add action Filter array to filter out only folders.

 

Then in the action Create HTML table, select Body from Filter array, custom the fields:

Path:

join(take(split(item()?['{Path}'],'/'),2),'/')

An image for your reference.

1.PNG

 

Best regards,

Mabel

 

 

Community Support Team _ Mabel Mao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

DesignerMat
Level: Powered On

Re: Filter SubDomain Level

Thanks for your answers, sorry in advance as I am new to the more complicated side of Flow.

 

I am trying to get a list of all the new folders created in a SharePoint library within a time frame (1 week). Then send an email digest. I only want to show folders only to a certain subdomain folder 'depth' as 4th level folders lack context for the reader of the email. So I think I need a blend of both of your answers @Brad_Groux & @v-yamao-msft .

 

But I am stuck joining the two to do the above.

 

Thanks

Community Support Team
Community Support Team

Re: Filter SubDomain Level

Hi @DesignerMat ,

 

To filter out files that created within a time frame, I would suggest use the action Filter array with the following code:

@and(greaterorequals(formatdatetime(item()?['Created'], 'yyyy-MM-dd'),adddays(utcnow(),-7,'yyyy-MM-dd')),lessorequals(formatdatetime(item()?['Created'],'yyyy-MM-dd'),utcnow('yyyy-MM-dd')))

 

After the action, adding Create HTML table action to get the level of subfolders you want.

 

The reason that I don’t use Filter query in action Get files is that standard Created property is not able to be used in the Filter query functions. So we have to use Filter array instead if you want to generate a summary list later.

1.PNG

 

Best regards,

Mabel

 

Community Support Team _ Mabel Mao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
DesignerMat
Level: Powered On

Re: Filter SubDomain Level

Thanks for your answer I am getting closer to what I am needing. I copied your code sorting the created dates however it seems to be not pulling a folder created today. On the get file (properties) there is a limit to how many files can be pulled is that effecting it, therefore, I may need to do a filter on the get file (properties) instead? @v-yamao-msft 

 

I have also played with changing the date range to '-21' and no results made it through the filter.

Super User
Super User

Re: Filter SubDomain Level


@DesignerMat wrote:

Thanks for your answer I am getting closer to what I am needing. I copied your code sorting the created dates however it seems to be not pulling a folder created today. On the get file (properties) there is a limit to how many files can be pulled is that effecting it, therefore, I may need to do a filter on the get file (properties) instead? @v-yamao-msft 

 

I have also played with changing the date range to '-21' and no results made it through the filter.


All of the Get files actions has a filter query - 

FilterQuery.png

SharePoint API has a hard limit of 600 API calls per 60 seconds, so you can also build in delays into your Flow.

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

DesignerMat
Level: Powered On

Re: Filter SubDomain Level

Thanks, @Brad_Groux - I have tried using the filter query provided provide by @v-yamao-msft but when I use it in the filter area of the "Get Files - (Properties)" it throws up an error. I am assuming that the filter expression needed for Get-Files needs to be formatted differently. 

 

and(greaterorequals(formatdatetime(item()?['Created'], 'yyyy-MM-dd'),adddays(utcnow(),-21,'yyyy-MM-dd')),lessorequals(formatdatetime(item()?['Created'],'yyyy-MM-dd'),utcnow('yyyy-MM-dd')))

The error is as follows

InvalidTemplate. Unable to process template language expressions in action 'Get_files_(properties_only)' inputs at line '1' and column '2613': 'The template language function 'formatdatetime' expects its first parameter to be of type string. The provided value is of type 'Null'. Please see https://aka.ms/logicexpressions#formatdatetime for usage details.'.
Super User
Super User

Re: Filter SubDomain Level


@DesignerMat wrote:

Thanks, @Brad_Groux - I have tried using the filter query provided provide by @v-yamao-msft but when I use it in the filter area of the "Get Files - (Properties)" it throws up an error. I am assuming that the filter expression needed for Get-Files needs to be formatted differently. 

 

and(greaterorequals(formatdatetime(item()?['Created'], 'yyyy-MM-dd'),adddays(utcnow(),-21,'yyyy-MM-dd')),lessorequals(formatdatetime(item()?['Created'],'yyyy-MM-dd'),utcnow('yyyy-MM-dd')))

The error is as follows

InvalidTemplate. Unable to process template language expressions in action 'Get_files_(properties_only)' inputs at line '1' and column '2613': 'The template language function 'formatdatetime' expects its first parameter to be of type string. The provided value is of type 'Null'. Please see https://aka.ms/logicexpressions#formatdatetime for usage details.'.

What @v-yamao-msft gave you was a filter array, not a filter query. They are two different things. The filter query is within the step (action/trigger) level:FilterQuery.png

An array is it's own step: FilterArray.PNG

The code @v-yamao-msft provided was for an array. Please see the Use filter array action documentation

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

DesignerMat
Level: Powered On

Re: Filter SubDomain Level

Thankyou @Brad_Groux I was confused. I have made a very basic filter using today's date (if 'Created' = 'Today's Date'). But it still does not pull a folder I created today. Is the limit of the API affecting the results or does the filter run then the API pulls the files?

Screen Shot 2019-05-14 at 11.37.06 AM.pngScreen Shot 2019-05-14 at 11.36.54 AM.png

Super User
Super User

Re: Filter SubDomain Level

What's the Today's Date array have in it? The ODATA query needs to be a string, and you're piping in an array. You could put in a time-based expression, like so: 

Also, depending on what you are piping in, you may not need the 'single quotes.' 

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

DesignerMat
Level: Powered On

Re: Filter SubDomain Level

This still generates no files there are several files/folders that have been created in the last 30 days. 

 

Screen Shot 2019-05-14 at 12.12.12 PM.png

 

Super User
Super User

Re: Filter SubDomain Level

Expressions don't need the 'single quotes' around them, try removing those. Also, I'd utlize the subtractFromTime expression rather using -30 days in the addDays expression.

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

Community Support Team
Community Support Team

Re: Filter SubDomain Level

Hi @DesignerMat ,

 

Instead of using Filter query of action Get files (properties only), I used action Filter array in my scenario.

 

The following query work fine on my side, image for your reference.

 

The function is:

addDays(utcNow(),-30,'yyyy-MM-ddTHH:mm:ssZ')

1.PNG2.PNG

 

 

 

Best regards,

Mabel

Community Support Team _ Mabel Mao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
DesignerMat
Level: Powered On

Re: Filter SubDomain Level


@v-yamao-msft wrote:

Hi @DesignerMat ,

 

Do you want to get a summary list of certain level of the subfolder?

 

Please check if the following workaround will work for you.

 

Under the action Get files (properties only), add action Filter array to filter out only folders.

 

Then in the action Create HTML table, select Body from Filter array, custom the fields:

Path:

join(take(split(item()?['{Path}'],'/'),2),'/')

An image for your reference.

1.PNG

 

Best regards,

Mabel

 

 


Hi @v-yamao-msft ,

 

Thanks for your help so far. I had a similar question as I am nearing the completion of my flow. Is there any way to limit the number of folders represented in the folder path.

 

Example current code

join(take(split(item()?['{Path}'],'/'),4),'/')

Returns:

Folder Level A/Folder Level B/Folder Level C/Folder Level D

 

What I want to return:

Folder Level C/Folder Level D    or    Folder Level B/Folder Level C

 

As this is going in an email I am wanting to minimize the folder path length and as Folder A & Folder B are standard they are just complicating things.

 

Thanks

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

firstImage

Incoming: New and improved badges!

We've given our badges an overhaul and also added some brand new ones!

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Power Automate Community Video Gallery!

Top Kudoed Authors (Last 30 Days)
Users online (4,829)