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.
Thanks for the help in advance
Solved! Go to Solution.
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.
Best regards,
Mabel
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.
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!
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.
Best regards,
Mabel
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
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.
Best regards,
Mabel
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.
@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 -
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!
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.'.
@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:
An array is it's own step:
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!
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?
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!
This still generates no files there are several files/folders that have been created in the last 30 days.
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!
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')
Best regards,
Mabel
@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.
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
User | Count |
---|---|
102 | |
39 | |
29 | |
24 | |
16 |
User | Count |
---|---|
132 | |
52 | |
51 | |
37 | |
26 |