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 Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (1,898)