I want to setup a reminder message in teams, to remind people to complete an inspection when their shift starts. How can I get the user who is on an active shift? So that I can then message them.
So far I've got a scheduled flow, followed by `Get a Shift`, followed by `Post a message as the flow bot to a user` but I don't know how to find the Current Shift, or whether there is a better approach.
Thanks
Solved! Go to Solution.
Hi @itsmelmon ,
I believe this would be possible by using the start end end date an comparing it to the current date time with the utcnow(). However, in order to make this to work I am converting the times from Shifts and the current time to ticks per minute.
In my example I am using the List Shifts action btw.
1. Add a List All Shifts action
2. Add a condition action and add the following two expressions to it. The first one is looking at the start time and the second one at the end time of the shift. In both cases I am converting it to ticks per minute (that's why I am dividing it by 600000000). And I am using an empty to check to ignore the field value if it's empty. I noticed that some shifts where listed without start times.
Update expression below. Had a small typo.
if(empty(items('Apply_to_each')?['sharedShift/startDateTime']), 0, div(ticks(items('Apply_to_each')?['sharedShift/startDateTime']),600000000))
is less than or equal to
div(ticks(formatdatetime(utcnow(), 'yyyy-MM-ddTHH:mm:ssZ')), 600000000)
And I am also using
if(empty(items('Apply_to_each')?['sharedShift/endDateTime']), 0, div(ticks(items('Apply_to_each')?['sharedShift/endDateTime']),600000000))
is greater than or equal to
div(ticks(formatdatetime(utcnow(), 'yyyy-MM-ddTHH:mm:ssZ')), 600000000)
3. Collected the assigned to user id and post your message to teams 🙂
Hope this helps a bit?
Hi @itsmelmon ,
I believe this would be possible by using the start end end date an comparing it to the current date time with the utcnow(). However, in order to make this to work I am converting the times from Shifts and the current time to ticks per minute.
In my example I am using the List Shifts action btw.
1. Add a List All Shifts action
2. Add a condition action and add the following two expressions to it. The first one is looking at the start time and the second one at the end time of the shift. In both cases I am converting it to ticks per minute (that's why I am dividing it by 600000000). And I am using an empty to check to ignore the field value if it's empty. I noticed that some shifts where listed without start times.
Update expression below. Had a small typo.
if(empty(items('Apply_to_each')?['sharedShift/startDateTime']), 0, div(ticks(items('Apply_to_each')?['sharedShift/startDateTime']),600000000))
is less than or equal to
div(ticks(formatdatetime(utcnow(), 'yyyy-MM-ddTHH:mm:ssZ')), 600000000)
And I am also using
if(empty(items('Apply_to_each')?['sharedShift/endDateTime']), 0, div(ticks(items('Apply_to_each')?['sharedShift/endDateTime']),600000000))
is greater than or equal to
div(ticks(formatdatetime(utcnow(), 'yyyy-MM-ddTHH:mm:ssZ')), 600000000)
3. Collected the assigned to user id and post your message to teams 🙂
Hope this helps a bit?
Great - thank you! One question - what is the first "equal to" expression on your condition block?
@itsmelmon, that's the schedulinggroupid. I only wanted to use shifts from a specific group, in my case: TAG_e936e338-e6f6-4de2-a044-7bbc1f3314c0
@Expiscornovus Fantastic - thanks. I have just tried to run this, but it has thrown an error "Unable to process template language expressions for action 'Condition' at line '1' and column '13706': 'The template language function 'lessOrEquals' expects two parameter of matching types. The function was invoked with values of type 'String' and 'Integer' that do not match.'."
I believe the term:
Hi @itsmelmon,
You are right, I believe I made a copy/paste error in my post earlier. Sorry about that.
For both the startDateTime and endDatetime expressions it should be 0 instead of 'empty'.
if(empty(items('Apply_to_each')?['sharedShift/startDateTime']), 0, div(ticks(items('Apply_to_each')?['sharedShift/startDateTime']),600000000))
if(empty(items('Apply_to_each')?['sharedShift/endDateTime']), 0, div(ticks(items('Apply_to_each')?['sharedShift/endDateTime']),600000000))
The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.
Announcing a new way to share your feedback with the Power Automate Team.
Learn to digitize and optimize business processes and connect all your applications to share data in real time.
User | Count |
---|---|
69 | |
27 | |
22 | |
15 | |
13 |
User | Count |
---|---|
132 | |
43 | |
42 | |
34 | |
31 |