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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / When a shift is delete...
Power Automate
Unanswered

When a shift is deleted in StaffHub, remove entry from O365 calendar

(0) ShareShare
ReportReport
Posted on by

Hiya,

 

I'm a complete newbie to Flow so be gentle.

 

We've started using StaffHub at work and it would be great if our shifts were written to our O365 calendar. I've already used the existing template which writes them to our Calendar, but was wondering if there was a way to use a Flow to remove a deleted shift from the calendar too.

 

I've had a go but not had much luck so far. I will probably get there eventually, but was wondering whether someone could point me in the right direction or have possibly set one up.

 

Thanks in advance

Categories:
I have the same question (0)
  • v-xida-msft Profile Picture
    on at

    Hi @Anonymous,

     

    Could you please share a screenshot of your flow's configuration?

    Do you use the "Add new StaffHub shifts to your Office 365 calendar" built-in template to create your flow?

     

    I suppose that you use the "Add new StaffHub shifts to your Office 365 calendar" built-in template to create your flow, is it true? If you want to delete the corresponding shift (Outlook event) from your Outlook calendar, you should include the Shift ID within your Outlook event. When a shift is deleted from your StaffHub, you could find the specific the Outlook event based on the Shift ID and then delete it.

     

    I have made a test on my side and please take a try with the following workaround:

    Move StaffHub Shifts to Outlook calendar (use the "Add new StaffHub shifts to your Office 365 calendar" built-in template to create my flow😞8.JPG

     

    9.JPG

    Within Body field of the "Create event (V2)" action, type the Shift ID dynamic content of the "Get Shift" action.

     

    The flow works successfully as below:10.JPG

     

    11.JPG

     

    When a Shift is deleted in your StaffHub, remove event from your Office 365 Outlook calendar:

    • Add a "When a shift is deleted in a team" trigger, specify Team Id.
    • Add a "Get events (V2)" action, specify Calendar id.
    • Add a "Apply to each" action, input parameter set to output of "Get events (V2)" action.
    • Within "Apply to each" action, add a "HTML to text" action, Content field set to Body dynamic content of the "Get events (V2)" action. 

             Add a Condition, left input box set to output of "HTML to text" action, right input box set to Resource Id dynamic content of the trigger, within middle drop down, choose contains. Within "If/yes" branch of Condition, add a "Delete event" action, specify Calendar id, Id field set to Id dynamic content of the "Get events (V2)" action.

     

    Image reference:12.JPG

    The flow works successfully as below:13.JPG

     

     

    Best regards,

    Kris

  • Community Power Platform Member Profile Picture
    on at

    This is perfect! Thank you so much @v-xida-msft

     

    I do have one small issue though when it gets to "apply to each". I'm guessing at that point it's looking at every calendar entry for the ShiftID (in my case 199 entries) which is making the process run on a bit., is there a way to help speed it up? Perhaps add another condition like the subject line?

     

    Don't worry, I am trying to figure it out myself too. 🙂

     

    Thanks again

  • GabrielStJohn Profile Picture
    on at

    Hello, @Anonymous!

     

    I see that you appear to be satisfied with a reply to your post! If this reply helped you out and met your Flow needs, please mark it as the "Accepted Solution"!

     

    Much Appreciated!

    -Gabriel

  • lacrimas201 Profile Picture
    17 on at

    Hi

     

    I have followed the exact same steps as described here above.

    However, my removal flow seems to be going in error each time because of this reason:

     

    InvalidTemplate. Unable to process template language expressions for action 'Voorwaarde' at line '1' and column '1745': 'The template language function 'contains' expects its first argument 'collection' to be a dictionary (object), an array or a string. The provided value is of type 'Null'.'.

     

    Of course I have other appointments in my agenda without a shift idea.

     

    Anyone who can help with this?

     

    Thanks!

     

     

     

  • lacrimas201 Profile Picture
    17 on at

    Ok I have ran some more tests.

     

    When I rerun the flow, it works. The entry which was added via StaffHub is getting removed from the Outlook agenda. However since the flow is finding a lot of entries in the agenda (with only one matching entry with the shift ID), it says the error is for all other entries except for that one. Result in flow error.

     

    I can live with that, as long as the result is OK.

     

    But there is one thing I don't understand.

    I have 2 flows running, one is for adding an entry via StaffHub (and simultaneously the Outlook agenda is updated) and one for the removal of entries. As soon as I add a new shift via StaffHub, the 'add' flow starts to run. However the 'removal' run also starts to run, which is kinda weird since I did not remove anything.

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 538 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 405 Moderator

#3
abm abm Profile Picture

abm abm 252 Most Valuable Professional

Last 30 days Overall leaderboard