cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ClarkyPA365
Post Prodigy
Post Prodigy

Getting error when trying to delete records from Calendar in SharePoint

Hi,

I'm trying to schedule a flow to run once a month to delete all entries from an Events calendar, in SharePoint, going back 180 days for the first run then change that to 90 days.

I'm getting an error but not sure why??

I've used Get le 'Expression' but that seems to delete all events after the Now() date??

My current Flow is 

ClarkyPA365_0-1668693532069.png

The error i get is 

ClarkyPA365_1-1668693608965.png

 

 



1 ACCEPTED SOLUTION

Accepted Solutions
Sundeep_Malik
Community Champion
Community Champion

@ClarkyPA365 

 

Yes use EventDate only. Created date will be today only as you made them today. 

 

So, maybe just delete if event date has already passed more than 6 months. 

View solution in original post

19 REPLIES 19
Sundeep_Malik
Community Champion
Community Champion

Hey @ClarkyPA365 

 

Sorry was not able to help you on Monday. In the above, the only problem I see is you have used it rather than lt. 

Its a lower l and lower t. And you have use lower i and lower t. 

 

 

Try this. Lets see the result and go further.

Hi,

No worries I know we have day jobs to do 😊


Replaced i (lower case) with I (upper case) and still the same error??

ClarkyPA365_0-1668703262808.png

 

Sundeep_Malik
Community Champion
Community Champion

@ClarkyPA365 

 

You are using Capital I.

You have to use small L=l

 

Just copy this actually and paste it in filter query:

 

Created lt @{addDays(utcNow(),-180,'MM/dd/yyyy')}

Hi @Sundeep_Malik 

I really don't know what is going on??

Copied your expression

ClarkyPA365_0-1668761184341.png

The Flow fails with this 

ClarkyPA365_1-1668761251844.png

 



 

Sundeep_Malik
Community Champion
Community Champion

@ClarkyPA365 

 

I am also not sure whats wrong. 😶 

@Pstork1 

@v-yujincui-msft 

@v-liwei-msft 

@v-jefferni 

@v-qiaqi-msft 

@v-chengfen-msft 

 

Need help here please.

Sundeep_Malik
Community Champion
Community Champion

@ClarkyPA365 

 

Also attach single quotes around the expression

Created lt '@{addDays(utcNow(),-180,'MM/dd/yyyy')}'

 

My Bad, I missed the single quotes.

Hi @Sundeep_Malik ,

 

addDays(utcNow(),-180,'MM/dd/yyyy') this part needs to be written in expression.

vjefferni_2-1668762736278.png

Created lt 'addDays(utcNow(),-180,'MM/dd/yyyy')'

 

Best regards,

Community Support Team _ Jeffer Ni

If this post helps, then please consider Accept it as the solution to help the other members find it.

Hi,

I've tried it with the single quotes...

When I copy and paste the expression in it seems to remove the '@' sign and swiggle brackets

ClarkyPA365_0-1668762685763.png



Then when I add the expression in manually I get this

ClarkyPA365_1-1668762744349.png

 

Sundeep_Malik
Community Champion
Community Champion

@ClarkyPA365 

 

So 

@{}

is just the symbol of expression.

 

So lets say, for array []

square brackets is the symbol, for a expression in power automate @{} is the symbol. 

 

So, if you directly write it in the expression, then there is no need to write @ {} 

but if you are just typing it then if you write @ {}   

Power Automate will automatically understand you are typing an expression. 

 

I hope I was able to explain it properly??

Hi, @Sundeep_Malik 

Thank you I do understand 🙂

I've tried using Event ge instead of Created lt and this works in away.  
It deletes all entries back to May this year which is 6mths but also deletes all future events??  So entries for Jan to May 2022 are still visible but after May 2022 no entries show

I tested by adding events in for the last few days of November, some in December, January 2023 and these were all deleted??

Sundeep_Malik
Community Champion
Community Champion

@ClarkyPA365 

Instead of ge, write lt or le in that. 

Event ge expression

means it will delete all the events from 6 months before to future

Write 

Event lt expression

Event le expression

So, now write this:

Event lt 'addDays(utcNow(),-180,'MM/dd/yyyy')'

 

Or

 

Event lt '@{addDays(utcNow(),-180,'MM/dd/yyyy')}'

This will only delete older than 6 months. 

 

Gaurav1687
New Member

@ClarkyPA365 

 

 
use Created le 'expression result' and than try below given formula in expression as is and put single quotes at both side of expression result
addDays(utcNow(), -180,'MM/dd/yyyy')
 
 
see image this is how it will be look like
Gaurav1687_0-1668769668057.png

 

 

Hi,

Just wondering if this expression Created for this test purpose may be wrong.

As when the previous flows have deleted all the entries, I Create new ones, for testing, so the creation date for all of them will be the same day and not 180 days ago??

So, would EventDate be better used??

When I tested the above no entries were deleted

you can try 

formatDateTime(utcNow(), 'MM/dd/yyyy') than for testing purpose
Sundeep_Malik
Community Champion
Community Champion

@ClarkyPA365 

 

Yes use EventDate only. Created date will be today only as you made them today. 

 

So, maybe just delete if event date has already passed more than 6 months. 

Hi,

Tried EventDate only

ClarkyPA365_0-1668776755434.png

and still get error advising this 

ClarkyPA365_1-1668776808664.png

 




Sundeep_Malik
Community Champion
Community Champion

@ClarkyPA365 

 

This time you forgot to write le/lt between event date and expression.

 

Hi @Sundeep_Malik 

Sorry been a long day 😆

It worked 😁
Entries in May and months before are deleted and entries from May 19/11 onwards are still visible.

Thank you all for your assistance 👍 



The problem with the query you provided is that its missing the single quotes around the date value.  When you add them it will work.

Created lt '@{addDays(utcNow(),-180,'MM/dd/yyyy')}'


-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Helpful resources

Announcements
Power Automate News & Announcements

Power Automate News & Announcements

Keep up to date with current events and community announcements in the Power Automate community.

Community Calls Conversations

Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Automate Community Blog

Power Automate Community Blog

Check out the latest Community Blog from the community!

Users online (5,353)