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
Ignite 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Super User 2 - 2022 Congratulations

Welcome Super Users

The Super User program for 2022 - Season 2 has kicked off!

September Events 2022

Check out all of these events

Attend in person or online, there are incredible conferences and events happening all throughout the month of September.

Users online (2,920)