cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
a-mccormack
Microsoft
Microsoft

Error Handling

Hi All,

 

I have a button that deletes an event in Outlook and works just fine. If the event doesn't exist it should notify the user or at least exit. I'm not sure why but I cannot get the IfError function to work. Or maybe I should use something else? Code below. Thanks in advance for any help.

amccormack_0-1653670403054.png

 

 

IfError(
With({idCalendarEntry:
         First(
            Office365Outlook.GetEventsCalendarViewV3(
            _myCalendarId,
            Concatenate(DatePicker1_1.SelectedDate, " ", If(Toggle1.Value=true,"00:00:00",TextInput7_1.Text)),
	        Concatenate(DatePicker1_2.SelectedDate, " ", If(Toggle1.Value=true,"23:59:59",TextInput7_2.Text)),
                    {search:Concatenate("Event: ",adsComboboxEvents_2.Selected.structureName)}
             ).value
            )
       },
    Office365Outlook.CalendarDeleteItemV2 (
            _myCalendarId,
           idCalendarEntry.id                    
    )), Notify ("Event Does not Exist in Outlook Calendar"))

 

1 ACCEPTED SOLUTION

Accepted Solutions
Ben_Hoople
Advocate I
Advocate I

thats some high-level powerapps coding, so i appreciated just reading it.

That being said the code looks good, the problem may be with powerapps itself 😞

 

if i can break it down into simple terms:

 

IfError(
   With({record : First()},Delete),
   Notify()
);

 

I think whats happening is the IfError is looking at the With() function for an error (which it doesn't error) but the delete function inside the With() does.

 

I might try this a couple of ways, to work with your code i might try this:

With(
   {record : First()},IfError(Delete, Notify())
);

 

or:

UpdateContext({varCalendarToDelete: First("Get calendar")});

If(IsEmpty(varCalendarToDelete), Error(), Delete());


like anything in coding, theres a million ways to do something, and as long as something works and its consistent, then its a perfectly valid solution.

 

Hope this helps!

View solution in original post

2 REPLIES 2
Ben_Hoople
Advocate I
Advocate I

thats some high-level powerapps coding, so i appreciated just reading it.

That being said the code looks good, the problem may be with powerapps itself 😞

 

if i can break it down into simple terms:

 

IfError(
   With({record : First()},Delete),
   Notify()
);

 

I think whats happening is the IfError is looking at the With() function for an error (which it doesn't error) but the delete function inside the With() does.

 

I might try this a couple of ways, to work with your code i might try this:

With(
   {record : First()},IfError(Delete, Notify())
);

 

or:

UpdateContext({varCalendarToDelete: First("Get calendar")});

If(IsEmpty(varCalendarToDelete), Error(), Delete());


like anything in coding, theres a million ways to do something, and as long as something works and its consistent, then its a perfectly valid solution.

 

Hope this helps!

a-mccormack
Microsoft
Microsoft

I couldn't get the above to work but am using the advice you gave to help solve my problem. I think you pointed me in the right direction. Thank you!

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.

365 EduCon 768x460.png

Microsoft 365 EduCon

Join us for two optional days of workshops and a 3-day conference, you can choose from over 130 sessions in multiple tracks and 25 workshops.

Users online (2,418)