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 Apps / Adding event from drop...
Power Apps
Answered

Adding event from drop down to user calendar

(1) ShareShare
ReportReport
Posted on by 118

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

Categories:
I have the same question (0)
  • Verified answer
    v-xiaochen-msft Profile Picture
    Microsoft Employee on at

    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

  • Siamak Profile Picture
    118 on at

    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

     

     

  • Siamak Profile Picture
    118 on at

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

  • Waegemma Profile Picture
    583 Super User 2024 Season 1 on at

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

     

    Marc

  • Verified answer
    Siamak Profile Picture
    118 on at

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

     

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 Apps

#1
11manish Profile Picture

11manish 530

#2
WarrenBelz Profile Picture

WarrenBelz 459 Most Valuable Professional

#3
Haque Profile Picture

Haque 314

Last 30 days Overall leaderboard