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 / Add/Remove Events on c...
Power Apps
Answered

Add/Remove Events on calendar

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hi Guys,

 

I have a sharepoint list with a list of appointments, I would like to create an event in the outlook calendar when an new appointment is created, I have the date and times in columns, the date is in date format, but the time is in text format, someone can help me on this?

I´m using this code:

"Office365.CalendarPostItem(MyCalendar;ThisItem.hora_fim;ThisItem.hora_inicio;"Testexx";DateTimeCreated:Text(ThisItem.data_agendamento;ShortDate)})"

 

Sharepoint list:

 

 

Sharepoint.png
Categories:
  • WarrenBelz Profile Picture
    156,526 Most Valuable Professional on at

    Hi @Anonymous ,

    Try TimeValue - it should help you convert it.

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more. It also closes the item.

  • Verified answer
    v-siky-msft Profile Picture
    Microsoft Employee on at

    @Anonymous 

    I suggest you use the latest version function: Office365Outlook.V4CalendarPostItem().

    1. Go to add Office365Outlook Connection to Data source.

    2. Modify the formula as below:

     

    Office365Outlook.V4CalendarPostItem(LookUp(Office365Outlook.CalendarGetTablesV2().value,name="Calendar").id,
    "Subject",
    DateValue(Text(ThisItem.<DateColumnName>))+Time(Value(Left(ThisItem.<Start Time>,2)),Value(Right(ThisItem.<Start Time>,2)),0),
    DateValue(Text(ThisItem.<DateColumnName>))+Time(Value(Left(ThisItem.<End Time>,2)),Value(Right(ThisItem.<End Time>,2)),0),
    "(UTC) Coordinated Universal Time")

     

    Sik

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Hi @v-siky-msft ,

     

    Thanks for the tip, but still doesn´t work......the formula doesn´t show any errors, so I think is something related with my local calendar.

     
     

     

    I Set a variable to get My calendar ID and Named "MyCalendar" 

    Collect(CalendarLocalizedLabel;{Value:"Calendar"};{Value:"Calendário"};{Value:"Calendario"})

    Set(MyCalendar; LookUp(Office365.CalendarGetTablesV2().value; name = LookUp(CalendarLocalizedLabel;Value=name).Value).id)

     

     image.png

     

    I separated the formula to test the hypotheses, and both (date and time) are working as expected, as seen in the image below:

    image.png

     

    Capturar3.JPG

    Any other ideas??

  • v-siky-msft Profile Picture
    Microsoft Employee on at

    @Anonymous 

     

    I made a test again and it can work well.

    Please ensure the Calendar ID is correct, and change the TimeZone to your Local.

    Snipaste_2020-02-06_10-35-54.pngSnipaste_2020-02-06_10-37-27.png

    If it still doesn't work, could you please create a new test app and try again?

    Sik

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Morning @v-siky-msft !!!

     

    Well, I´ve try some variations of the formula and experienced some weird situations......

     

    First try, using CalendarPostItem:

     Office365Outlook.CalendarPostItem(MyCalendar;
    DateValue(Text(ThisItem.'Appointment Date'))+Time(Value(Left(ThisItem.'End Time';2));Value(Right(ThisItem.'End Time';2));0);
    DateValue(Text(ThisItem.'Appointment Date'))+Time(Value(Left(ThisItem.'Start Time';2));Value(Right(ThisItem.'Start Time';2));0);
    "Test”;{StartTimeZone:"E. South America Standard Time";EndTimeZone:"E. South America Standard Time"})

     

    image.png

     

    Odd facts.....

    Even with the times fixed in the sharepoint, he is creating the event with 3 more hours according to the time zone ...... which doesn't make sense since I don't want him to add hours, just create with this timezone.

     

    image.png

     

    image.png

     

    Second try....

    Office365Outlook.V4CalendarPostItem(MyCalendar;"Test";

    DateValue(Text(ThisItem.'Appointment Date'))+Time(Value(Left(ThisItem.'Start Time';2));Value(Right(ThisItem.'Start Time';2));0);

    DateValue(Text(ThisItem.'Appointment Date'))+Time(Value(Left(ThisItem.'End Time';2));Value(Right(ThisItem.'End Time';2));0);

    "(UTC-03:00) Brasilia")

     

    Nothing Happend!!!! Even without erros…………….

     

    Third try…..

     Office365Outlook.CalendarPostItem(MyCalendar;
    DateValue(Text(ThisItem.'Appointment Date'))+Time(Value(Left(ThisItem.'End Time';2));Value(Right(ThisItem.'End Time';2));0);
    DateValue(Text(ThisItem.'Appointment Date'))+Time(Value(Left(ThisItem.'Start Time';2));Value(Right(ThisItem.'Start Time';2));0);
    "Test”;{StartTimeZone: "(UTC-03:00) Brasilia";EndTimeZone: "(UTC-03:00) Brasilia"})

     

    Nothing Happend!!!! Even without erros…………….

     

    Fourth try…

    Perhaps the most complex attempt ..... I removed part of the formula and put it in a label to make it easy ..... start and end date and time went to lblStart and lblEnd

     

     

    Office365Outlook.CalendarPostItem(MyCalendar;lblEnd;lblStart;"Test4")

     

    image.png

     

    This time I didn´t set any timezone......the result.....

    Bingo.....it creates the appointment, and at first at the same time as this on the sharepoint ......

    image.png

     

    But, when I open the appointment, the times are different from the one shown on the main screen!!!!

    What a F……..how odd is that?

     

    image.png

     

    @v-siky-msft, in fact the solution that you provided it could be perfectly executed for those who are in UTC, if you prefer, I can close this post with the solution that you gave and open another with this time zone discussion, or what do you think?

     

    George

     

  • v-siky-msft Profile Picture
    Microsoft Employee on at

    @Anonymous 

    That could be a Time Zone setting issue.

    Could you go to check the TimeZone Setting of Office 365?

    1. Login to Office365: https://www.office.com/?auth=2 

    2. Check if the TimeZone is set to Local

    Snipaste_2020-02-08_11-02-36.png

    Sik

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    @v-siky-msft, thank you very much for your patience!

     

    Unfortunately the regional settings are blocked by the organization and I couldn't check which ones are ....

    I spent the day today doing some tests and managed to get around the problem by adding 3 hours to the formula, now it works well ..... what caught my attention was the fact that the formula with "Office365Outlook.V4CalendarPostItem" did not work at all.....

     

    I tested them all and they all worked very well except for Office365Outlook.V4CalendarPostIt, as I said before, when I was executing the formula it did not add the appointment in the calendar, but did not give an error, so I decided to create a collection in PowerApps and direct to my calendar, for my surprise, all the events created before with this code were there!

     

    image.png

    Works for 3 of 4 them....

     

    image.png

    And they (3) are all good!

    image.png

     

    But when I go to the gallery, it´s possible to see that it creates the V4 for event there, but I can´t see this event on outlook!!

     

    image.png


    I think I will keep with this formula, it worked well and will fulfill my purpose!

    "Office365Outlook.V3CalendarPostItem(MyCalendar;"TestV3";DateValue(Text(ThisItem.'Appointment Date'))+Time(Value(Left(ThisItem.'Start Time';2))-3;Value(Right(ThisItem.'Start Time';2));0);DateValue(Text(ThisItem.'Appointment Date'))+Time(Value(Left(ThisItem.'End Time';2))-3;Value(Right(ThisItem.'End Time';2));0);{TimeZone:"(UTC-03:00) Brasilia";Reminder: "30"})"

     

    Now I need to find a way to remove this event automatically from the calendar when the user cancels the reservation, any idea how to do?

  • v-siky-msft Profile Picture
    Microsoft Employee on at

    @Anonymous 

     

    If you want to remove the event, please try with Office365Outlook.CalendarDeleteItem_V2 function and V4CalendarGetItems function

    Office365Outlook.CalendarDeleteItemV2(CalendarID, LookUp(Office365Outlook.V4CalendarGetItems(CalendarID,subject=<SubjectName>).id)

     Just enter the Subject you want to cancel to <SubjectName>

    Sik

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 402 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 328

#3
WarrenBelz Profile Picture

WarrenBelz 296 Most Valuable Professional

Last 30 days Overall leaderboard