cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
__markb
Frequent Visitor

Setting Automatic Reply (OoF) based on Shifts

Hi everyone! I was wondering if someone could help me set my Automatic Replies based on where my shift is based.

 

We currently have 4 options in our shifts - Home, Office, Leave, Sick

 

What I have at the moment is:

 

1. Repeat the trigger everyday at midnight

Screen Shot 2021-03-11 at 11.13.18 am.jpg

 

2. Get my profile

Screen Shot 2021-03-11 at 11.13.54 am.jpg

 

3. Get the current date and time

Screen Shot 2021-03-11 at 11.13.59 am.jpg

 

4. List all the shifts

Screen Shot 2021-03-11 at 11.14.10 am.jpg

 

I was following this forum post: https://powerusers.microsoft.com/t5/General-Power-Automate/Get-my-shifts-using-flow/m-p/384718/highl... but couldn't seem to get past the Select area.

 

I think that in the list shifts (step 4) I would pass in the Start Datetime from step 3.

 

Then I would parse the JSON.

 

Filter the array for both User ID and then get the next day entry.

 

If it matched "Leave" or "Sick", then set the Automatic Reply action - start time and end time of the shift.

 

Any help would be appreciated!

1 ACCEPTED SOLUTION

Accepted Solutions
DamoBird365
Microsoft
Microsoft

Hi @__markb 

 

You'll need to ensure that your date is in the correct format first, and can look to use the expression formatdatetime().  I had a case a few weeks ago where by adding a date, the filter returned nothing, my environment is still behaving the same but the affected user rebuilt his flow and it finally worked - I think it's maybe a bug so something to watch for.

 

DamoBird365_0-1615444403269.png

Anyway, once you have listed all of your shifts, you need to filter.  The get shifts action doesn't make thing easy for you as it doesn't return the shift user in the body, instead you get the GUID for that User which can be obtained with another action get user profile.

1234.PNG

 

Once filtered you can apply a condition on the top "Notes" field?  Take a look at the body output of a history run to discover the field you are looking for but something as follows:

 

"sharedShift": {
"notes": "Office",
"startDateTime": "2021-03-04T07:15:00Z",
"endDateTime": "2021-03-04T16:15:00Z",
"theme": "blue",
"activities": []
}

 

Your top shift returned in your filter array (assuming more than one) will be equal to the expression:

body('Filter_array')?[0]?['sharedShift']?['notes']

 

You can use the condition action on this.

 

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

View solution in original post

1 REPLY 1
DamoBird365
Microsoft
Microsoft

Hi @__markb 

 

You'll need to ensure that your date is in the correct format first, and can look to use the expression formatdatetime().  I had a case a few weeks ago where by adding a date, the filter returned nothing, my environment is still behaving the same but the affected user rebuilt his flow and it finally worked - I think it's maybe a bug so something to watch for.

 

DamoBird365_0-1615444403269.png

Anyway, once you have listed all of your shifts, you need to filter.  The get shifts action doesn't make thing easy for you as it doesn't return the shift user in the body, instead you get the GUID for that User which can be obtained with another action get user profile.

1234.PNG

 

Once filtered you can apply a condition on the top "Notes" field?  Take a look at the body output of a history run to discover the field you are looking for but something as follows:

 

"sharedShift": {
"notes": "Office",
"startDateTime": "2021-03-04T07:15:00Z",
"endDateTime": "2021-03-04T16:15:00Z",
"theme": "blue",
"activities": []
}

 

Your top shift returned in your filter array (assuming more than one) will be equal to the expression:

body('Filter_array')?[0]?['sharedShift']?['notes']

 

You can use the condition action on this.

 

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

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Users online (4,824)