cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper I
Helper I

Add/Remove Events on calendar

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:

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Support
Community Support

@demarchiori 

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

View solution in original post

8 REPLIES 8
Highlighted
Super User III
Super User III

Hi @demarchiori ,

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.

Highlighted
Community Support
Community Support

@demarchiori 

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

View solution in original post

Highlighted

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??

Highlighted

@demarchiori 

 

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

Highlighted

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

 

Highlighted

@demarchiori 

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

Highlighted

@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?

Highlighted

@demarchiori 

 

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

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Community Highlights

Community Highlights

Check out the Power Platform Community Highlights

Top Solution Authors
Top Kudoed Authors
Users online (12,162)