PowerApps: Create an All-Day Calander Event for Microsoft Group

This blog will discuss creating a Calander Event for Group from Canvas Apps. Group Can be Microsoft 365, Distribution List, or Security.

Microsoft Groups

    • Go to the Micorosft Admin center
    • Click “Teams & groups” on the left navigation
    • Get Group information that needs to create an event

Scenario 1:

Have a requirement to create a Calander event for the group from PowerApps. 

PowerApps Code

Office365Groups.CreateCalendarEventV2(
“Group ID”, //Get the Group ID from M365
“New Client Project Meeting from PowerApps”,
{
dateTime: DateTimeValue(StartDatePicker.SelectedDate & “T00:00:00”),
timeZone: UTC
},
{
dateTime: DateTimeValue(EndDatePicker.SelectedDate & “T00:00:00”),
timeZone: UTC
},
{
body: {
content: “New Project”,
contentType: “Text”
},
location: {displayName: “Virtual”},
importance: “Normal”,
isAllDay: false,
isReminderOn: false,
showAs: “Busy”,
responseRequested: false
}
)

Scenario 2:

Have a requirement to create an ALL DAY Calander event for the group from PowerApps. 

PowerApps Code

Office365Groups.CreateCalendarEventV2(
“Group ID”, //Get the Group ID from M365
“New Client Project Meeting from PowerApps”,
{
dateTime: DateTimeValue(StartDatePicker.SelectedDate & “T00:00:00”),
timeZone: UTC
},
{
dateTime: DateTimeValue(EndDatePicker.SelectedDate & “T00:00:00”),
timeZone: UTC
},
{
body: {
content: “New Project”,
contentType: “Text”
},
location: {displayName: “Virtual”},
importance: “Normal”,
isAllDay: true,
isReminderOn: false,
showAs: “Busy”,
responseRequested: false
}
)

Have you ever seen this error?

The Event.Start property for an all-day event needs to be set to midnight

Unfortunately, Powerapps throws the above error when creating an all-day event even though you have the proper Power Fx Code.

Work Around

Looks like this is a product Bug causing an issue with creating an event. We can use Power Automate as a workaround to create an event.

Steps:

  1. Create Power Automate Flow which Creates an Event
  2. Call the Power Automate with the required Input Parameters

 

  1. Create Power Automate Flow which Creates an Event

We can create Power Automate in two ways

  1. Within PowerApps
    • Click “Power Automate” on the left Navigation
    • Click ” Add flow”
    • This creates a new Power Automate with Trigger selected
  2. Outside PowerApps
    • Create Instant Cloud Flow from the Navigation
    • Select the Trigger “PowerApps”
    • Add a step, “Initialize Variable”
      • Name: Initialize Start Date
      • Value: Ask in PowerApps

  • Add the next Step, “Create a group event (V2)
    • Set Start Time – formatDateTime(concat(variables(‘Start Date’),’T00:00:00′))
    • End Time – addDays(formatDateTime(concat(variables(‘Start Date’),’T00:00:00′)),1)
    • Other Required Information

2. Call the Power Automate with the required Input Parameters

  • Add the Power Automate to the App if Power Automate created outside PowerApps
    • Using “Add flow”
    • Select the Power Automate that you created
  • If you create Power Automate from PowerApps, then it should display automatically.
    • Set “OnSelect” property of the button to

Conclusion

We can create a group calendar event using PowerApps and for All-day events using Power Automate as a workaround.

Enjoy working PowerApps!

Leave a Reply

Your email address will not be published. Required fields are marked *