web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Message person on Shif...
Power Automate
Answered

Message person on Shift in Teams

(0) ShareShare
ReportReport
Posted on by 26

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

Categories:
I have the same question (0)
  • Verified answer
    Expiscornovus Profile Picture
    33,846 Most Valuable Professional on at

    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)

     

     

     

    listshifts_condition.png

    3. Collected the assigned to user id and post your message to teams 🙂

     

    Hope this helps a bit?

  • itsmelmon Profile Picture
    26 on at

    Great - thank you! One question - what is the first "equal to" expression on your condition block?

  • Expiscornovus Profile Picture
    33,846 Most Valuable Professional on at

    @itsmelmon, that's the schedulinggroupid. I only wanted to use shifts from a specific group, in my case: TAG_e936e338-e6f6-4de2-a044-7bbc1f3314c0

  • itsmelmon Profile Picture
    26 on at

    @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:

     

    if(empty(items('Apply_to_each')?['sharedShift/startDateTime']), 'empty', div(ticks(items('Apply_to_each')?['sharedShift/startDateTime']),600000000))
     
    is returning a string?
  • Expiscornovus Profile Picture
    33,846 Most Valuable Professional on at

    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))

     

     

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Haque Profile Picture

Haque 594

#2
Valantis Profile Picture

Valantis 469

#3
11manish Profile Picture

11manish 364

Last 30 days Overall leaderboard