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

Read the day an event is on and create an event based on the output

Hi, 

 

I've been trying to figure this out for a while now, I've searched through the forum but cannot find anything which works.

What I'm wanting to do is automate populating a calendar, so when an event with a specific word in i.e 'Surgery' is added, I want the flow to find out what day of the week it is on (Monday - Friday) so I can use it in a condition. 

 

So if the event is added on a Wednesday, Thursday or Friday, I want it to create an event 2 days before, and if the event isn't on one of those 3 days I want it to add an event 4 days before.

 

I would add a photo of the flow, but I don't know how to on here...

 

Thanks

 

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: Read the day an event is on and create an event based on the output

Hi @RSAndrews94,

 

I assume that your scenario would be when an event is created in a calendar with a specific word “surgery” in the subject, you want to check the day of the week then create the event 2days or 4 days before.


To find out what day of the week it is on, please use workflow definition language function dayofweek, it will return the day of week component of a string timestamp, Sunday is 0, Monday is 1, and so on.


To create an event before 2 days or 4 days, you need to use the function adddays.


Please get more info on it at here:
https://docs.microsoft.com/en-us/azure/logic-apps/logic-apps-workflow-definition-language


Then the flow could be configured likes below.


The function used in the Compose action is dayofweek(triggerBody()?['Start']). It will return the day of week component of the Start time of the object.

dayofweek(triggerBody()?['Start'])


Then in the Condition, the or function is used to check whether it is Wednesday, Thursday or Friday. If yes, create the event 2 days before, if no, create the event 4 days before.

@or(equals(outputs('Compose'), 3),equals(outputs('Compose'), 4),equals(outputs('Compose'), 5))


In the Create event action, the function adddays(triggerBody()?['End'],-2) is used to create the event before 2days/4days.

adddays(triggerBody()?['End'],-2)

3.PNG

 

Please take this for a reference and try it on your side. if you need more help, please feel free post back.

 

Best regards,
Mabel Mao

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

2 REPLIES 2
Community Support Team
Community Support Team

Re: Read the day an event is on and create an event based on the output

Hi @RSAndrews94,

 

I assume that your scenario would be when an event is created in a calendar with a specific word “surgery” in the subject, you want to check the day of the week then create the event 2days or 4 days before.


To find out what day of the week it is on, please use workflow definition language function dayofweek, it will return the day of week component of a string timestamp, Sunday is 0, Monday is 1, and so on.


To create an event before 2 days or 4 days, you need to use the function adddays.


Please get more info on it at here:
https://docs.microsoft.com/en-us/azure/logic-apps/logic-apps-workflow-definition-language


Then the flow could be configured likes below.


The function used in the Compose action is dayofweek(triggerBody()?['Start']). It will return the day of week component of the Start time of the object.

dayofweek(triggerBody()?['Start'])


Then in the Condition, the or function is used to check whether it is Wednesday, Thursday or Friday. If yes, create the event 2 days before, if no, create the event 4 days before.

@or(equals(outputs('Compose'), 3),equals(outputs('Compose'), 4),equals(outputs('Compose'), 5))


In the Create event action, the function adddays(triggerBody()?['End'],-2) is used to create the event before 2days/4days.

adddays(triggerBody()?['End'],-2)

3.PNG

 

Please take this for a reference and try it on your side. if you need more help, please feel free post back.

 

Best regards,
Mabel Mao

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

RSAndrews94
Level: Powered On

Re: Read the day an event is on and create an event based on the output

This has worked perfectly! Thank you so much, I was struggling for a while trying to figure this out.

 

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 (5,318)