Bhubaneswar, Odisha, India
+91-8328865778
support@softchief.com

Power Automate Exception handling using Try Catch Finally

Power Automate Exception handling using Try Catch Finally

Most of the times when you design a Power Automate flow, you face run time errors due to data issue or environment issues. So this post will explain you how you can handle runtime errors in Power Automate.

Follow the below steps to implement TRY CATCH FINALLY BLOCKS in Power Automate.

Watch the video or scroll down to read the article step bystep.

Step 1: Create a flow with a trigger

Open Power Automate website and create a new flow. For this demo I have created an Instant Flow and taken 2 text parameters.

Step 2: Add a Scope for TRY Block and add actions

To implement TRY CATCH Block, Add an action called as Scope.

Scopes are used to combine multiple action inside a logical group. Inside the scope add a Dataverse action Add New Row. I wanted to created a student record so used Dataverse connector and added Add new Row action and assigned dynamic content to fields. You can rename the scope as TRY.

Before the Try Scope declare a variable as “SUCCESS.”. This variable will be used to store the actual error if there is any error in try scope otherwise the value remains as success if no error.

Step 3: Add a Scope FOR CATCH Block and add actions

Now add another scope after try scope and inside the scope add 2 actions. Parse JSON to parse the body result from Create Student step and extracting the error message from the JSON object and another action to set variable with error message. The error message is the JSON object available as output of parse JSON step.

NOTE: In Parse JSON it requires a schema. To copy the body schema run the flow with error and copy the body request data and use it in Parse JSON using Generate from Sample.

Step 4: Configure RUN AFTER for Catch Scope

This is important step. Click on 3 dots of Catch Scope and choose Configure Run After.

In the configure run after choose has failed. That means the CATCH SCOPE will only be called if TRY SCOPE FAILED.

Step 5 : Add Finally Scope and Configure Run After

Now add a Finally block so that irrespective of TRY block result the Finally block will execute. The finally scope will must execute if TRY BLOCK FAILS and Also for SUCCESS.

Configure Run After for Finally Block.

This time we have selected is Successful or skipped. The Catch scope will be success if there is an Error in Try scope. The Catch block will be Skipped if there is no error in TRY Block. For every scenario the finally block will excute.

TEST NOW: (Failed Result)

The variable store actual result.

TEST NOW: (SUCCESS Result)

Hope this helps.

You can enroll now !We are giving 30% discount on our Internship Program

Don’t miss the chance to participate in the upcoming Internship Program which will be done using Microsoft Dot Net Web Development Full Stack Technology. The new batch will be starting from May 20, 2024.  We will have most experienced trainers for you to successfully complete the internship with live project experience.

Why to choose Our Internship Program?

Industry-Relevant Projects
Tailored Assignments: We offer projects that align with your academic background and career aspirations.
Real-World Challenges: Tackle industry-specific problems and contribute to meaningful projects that make a difference.

Professional Mentorship
Guidance from Experts: Benefit from one-on-one mentorship from seasoned professionals in your field.
Career Development Workshops: Participate in workshops that focus on resume building, interview skills, and career planning.

Networking Opportunities
Connect with Industry Leaders: Build relationships with professionals and expand your professional network.
Peer Interaction: Collaborate with fellow interns and exchange ideas, fostering a supportive and collaborative environment.

Skill Enhancement
Hands-On Experience: Gain practical skills and learn new technologies through project-based learning.
Soft Skills Development: Enhance communication, teamwork, and problem-solving skills essential for career success.

Free Demo Class Available