cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Siamak
Helper II
Helper II

Adding event from drop down to user calendar

Hi

 

I have looked for solution to this for a long time without success. So any advice/help will be appreciated

 

I am writing a PowerApp that reads date and time of events from SharePoint lists and allow the use to select a specific instance  based on date. Date columns on the list are Date/time format. 

 

Powerapp-form.jpg

This works ok. I am now trying to add the details of the event, including the date and time, to the participants' (current user) calendar. I have tried various ways of doing this and have come up with the following code: 

 

Office365Outlook.V4CalendarPostItem(
    LookUp(Office365Outlook.CalendarGetTablesV2().value,name="Calendar").id,
"Subject - test",
DateTimeValue(Text(StartDateDropdown.SelectedText.Value)),
DateTimeValue(EndDateLabel),

"(UTC) Coordinated Universal Time")

 

However when testing I get the error 400 ""String was not recognized as a valid DateTime"

 

In my form, the formats are start date/time and End date/time are dropdown and text.

 

Thanks in advance

2 ACCEPTED SOLUTIONS

Accepted Solutions
v-xiaochen-msft
Community Support
Community Support

Hi @Siamak ,

 

Please try this:

Office365Outlook.V4CalendarPostItem(
    LookUp(Office365Outlook.CalendarGetTablesV2().value,name="Calendar").id,
"Subject - test",
Text( DateTimeValue(Text(StartDateDropdown.SelectedText.Value)),"yyyy-mm-ddThh:mm:ss"),
Text(DateTimeValue(EndDateLabel),""yyyy-mm-ddThh:mm:ss""),

"(UTC) Coordinated Universal Time")

 

If it doesn't work ,please provide the outputs of DateTimeValue(Text(StartDateDropdown.SelectedText.Value)) and DateTimeValue(EndDateLabel).

 

Best Regards,

Wearsky

View solution in original post

Thank you for your reply and effort. I haven't tested your suggestion as I have resolved this now. Here is what is working for me

Set(varUserCalendarId, 
    LookUp(Office365Outlook.CalendarGetTablesV2().value, 
           name="Calendar").id
);

/*Create the  entry in current user's calendar with 60 min reminder*/

Office365Outlook.V4CalendarPostItem(
      varUserCalendarId, 
      "Test subject" 
             Text(DateTimeValue(StartDateDropdown.SelectedText.Value),DateTimeFormat.UTC),
             Text(DateTimeValue(EndDateLabel.Text),DateTimeFormat.UTC),
      "UTC",
      {isReminderOn:true, reminderMinutesBeforeStart:60}
 );

 

View solution in original post

5 REPLIES 5
v-xiaochen-msft
Community Support
Community Support

Hi @Siamak ,

 

Please try this:

Office365Outlook.V4CalendarPostItem(
    LookUp(Office365Outlook.CalendarGetTablesV2().value,name="Calendar").id,
"Subject - test",
Text( DateTimeValue(Text(StartDateDropdown.SelectedText.Value)),"yyyy-mm-ddThh:mm:ss"),
Text(DateTimeValue(EndDateLabel),""yyyy-mm-ddThh:mm:ss""),

"(UTC) Coordinated Universal Time")

 

If it doesn't work ,please provide the outputs of DateTimeValue(Text(StartDateDropdown.SelectedText.Value)) and DateTimeValue(EndDateLabel).

 

Best Regards,

Wearsky

Many thanks for your suggestion. Unfortunately it doesn't work and I am still getting he same message when I test it. 

The  outputs of DateTimeValue(Text(StartDateDropdown.SelectedText.Value)) and DateTimeValue(EndDateLabel) are 11/5/23 7:00:00 and 2023/11/05 T10:00:00

ps: you have a double quote in 

Text(DateTimeValue(EndDateLabel),""yyyy-mm-ddThh:mm:ss"")

are they meant to be there? Because I get an error when I use them. So I am guessing it's a typo

 

 

Ok, thank you again. I have used a different code and it's all working as it should now.

Hi @Siamak ,

 

Hadn't seen you resolved it. This was my solution 🙂

 

 

Office365Outlook.V2CalendarPostItem(
    LookUp(Office365Outlook.CalendarGetTablesV2().value;name="Calendar").id;
"Subject - test";
DropdownStartDate.Selected.'NameOfYourStartDateColumn';
DropdownEndDate.Selected.'NameOfYourEndDateColumn')

 

 

DropdownStartDate items set to the column with the startdate.

DropDownEndDate to the corresponding enddate (control's DisplayMode set to view).

 

I used the V2CalendarPostItem because of this post: Solved: Re: Create Event in Outlook calendar - Date format... - Power Platform Community (microsoft....

 

Marc

Thank you for your reply and effort. I haven't tested your suggestion as I have resolved this now. Here is what is working for me

Set(varUserCalendarId, 
    LookUp(Office365Outlook.CalendarGetTablesV2().value, 
           name="Calendar").id
);

/*Create the  entry in current user's calendar with 60 min reminder*/

Office365Outlook.V4CalendarPostItem(
      varUserCalendarId, 
      "Test subject" 
             Text(DateTimeValue(StartDateDropdown.SelectedText.Value),DateTimeFormat.UTC),
             Text(DateTimeValue(EndDateLabel.Text),DateTimeFormat.UTC),
      "UTC",
      {isReminderOn:true, reminderMinutesBeforeStart:60}
 );

 

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Users online (4,521)