08-12-2021 12:47 AM
I’m in the process of designing a pipeline which will read all of the .pgp files from a sharepoint document library and then delete any over X amount of days.
To do this I am first using a Sharepoint Online - Search Items snap to search for all .pgp documents in the specified library.
However I can’t for the life of me get the filter working so that it leaves me with only files older than X days.
My Sharepoint snap returns the following and I want to filter on createdDateTime
So far I have attempted a filter snap using the following but that filters everything out.
Date.parse(jsonPath($, “$value[*].createdDateTime”)) < Date.now().minusDays(2)
I have noticed that if i amend this filter snap to the following it does work as i pass each individual array member (using the array position rather than the * above) but i need it to filter based on the entire array.
Date.parse(jsonPath($, “$value[1].createdDateTime”)) < Date.now().minusDays(2)
Any help would be greatly appreciated!
Solved! Go to Solution.
08-12-2021 01:12 AM
Hi @Pud24 ,
This is happening because you have array of objects and when you try to filter on createdDateTime, the filter snap will evaluate either to true or false but if a condition is true it will pass the whole array and if the condition is false nothing will pass.
You have to do the following:
Use the following expression: $value.filter(val => Date.parse(val.get("createdDateTime")) < Date.now().minusDays(2))
08-12-2021 01:12 AM
Hi @Pud24 ,
This is happening because you have array of objects and when you try to filter on createdDateTime, the filter snap will evaluate either to true or false but if a condition is true it will pass the whole array and if the condition is false nothing will pass.
You have to do the following:
Use the following expression: $value.filter(val => Date.parse(val.get("createdDateTime")) < Date.now().minusDays(2))
08-12-2021 01:49 AM
This worked perfectly - thank you!