web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / When the 'On Error' op...
Power Automate
Suggested Answer

When the 'On Error' option is not available in Power Automate Desktop

(0) ShareShare
ReportReport
Posted on by
How can I implement exception handling when the 'On Error' option is not available?
For instance, the 'Convert text to datetime' action does not support the 'On Error' option, so the flow stops when an error occurs.
I would appreciate any guidance on how to handle such cases.
Thank you in advance for your help.
 
No On Error
I have the same question (0)
  • Suggested answer
    Peter PP Profile Picture
    6 on at
    You can put your convert datetime action in an On Block Error action.
    In the On Block error options set to Continue Flow Run
    and you must also set the option:   Capture unexpected logic errors.
     
    I hope that helps. On Block Error with the "Capture unexpected logic errors" is the way to go for your example problem. 
     
    Please see the attached PDF with screenshots of a small flow I wrote to demonstrate the above.
     
    (Note: in the example I set a variable recording the failure. This is not needed, it's just an example. The only important thing is to use On Block Error and set "Capture unexpected logic errors" On.)
  • ryule Profile Picture
    929 Super User 2024 Season 1 on at
    Yep, as Peter PP says, use the On Block Error action: https://learn.microsoft.com/en-us/power-automate/desktop-flows/errors
  • Suggested answer
    Riyaz_riz11 Profile Picture
    3,893 Super User 2025 Season 2 on at
    Hi,

    Method 1: Pre-Validation (Recommended for Date Conversion)

    For 'Convert text to datetime' Action:

    1. Set Variable: TextToCheck = "2024-13-45"  # Invalid date example
    2. IF Statement: Check if text matches date pattern
       ├── Condition: TextToCheck matches regex pattern
       │   └── Pattern: ^\d{4}-\d{2}-\d{2}$ (for YYYY-MM-DD format)
       ├── IF True:
       │   ├── Convert text to datetime
       │   └── Continue with flow
       └── IF False:
           ├── Set Variable: ErrorMessage = "Invalid date format"
           └── Handle error (log, set default, etc.)

    Validation Patterns for Different Date Formats:

    • YYYY-MM-DD: ^\d{4}-\d{2}-\d{2}$

    • MM/DD/YYYY: ^\d{2}/\d{2}/\d{4}$

    • DD.MM.YYYY: ^\d{2}\.\d{2}\.\d{4}$

    • DD-MMM-YYYY: ^\d{2}-[A-Za-z]{3}-\d{4}$

    Method 2: Try-Catch Pattern Using Block Structure

    Implementation:

    1. Set Variable: ConversionSuccess = False
    2. Set Variable: ConvertedDate = ""
    3. Set Variable: ErrorOccurred = False
    
    4. Block: Try Conversion
       ├── Convert text to datetime
       │   ├── Input: %TextToConvert%
       │   └── Output: ConvertedDate
       ├── Set Variable: ConversionSuccess = True
       └── [Continue with success logic]
    
    5. Block: Catch (Error Handler)
       ├── Set Variable: ErrorOccurred = True
       ├── Set Variable: ErrorMessage = "Date conversion failed"
       └── [Error handling logic]

    Method 3: Advanced Date Validation Function

    Custom Date Validation:

    1. Set Variable: DateText = "2024-02-30"
    2. Set Variable: IsValidDate = False
    
    3. Split Text: Split DateText by "-"
       └── Output: DateParts
    
    4. IF Statement: Check if DateParts count = 3
       ├── IF True:
       │   ├── Set Variable: Year = DateParts[0]
       │   ├── Set Variable: Month = DateParts[1]
       │   ├── Set Variable: Day = DateParts[2]
       │   
       │   ├── IF Statement: Validate Year (1900-2100)
       │   │   └── Condition: Year >= 1900 AND Year <= 2100
       │   
       │   ├── IF Statement: Validate Month (1-12)
       │   │   └── Condition: Month >= 1 AND Month <= 12
       │   
       │   ├── IF Statement: Validate Day
       │   │   ├── IF Month in [1,3,5,7,8,10,12]: Day <= 31
       │   │   ├── IF Month in [4,6,9,11]: Day <= 30
       │   │   └── IF Month = 2: Day <= 28 (or 29 for leap years)
       │   
       │   └── IF All Valid: Set IsValidDate = True
       └── IF False: Set IsValidDate = False
    
    5. IF Statement: Check IsValidDate
       ├── IF True: Convert text to datetime
       └── IF False: Handle invalid date

    Method 4: Exception Handling with Subflows

    Main Flow:

    1. Run Subflow: "ValidateAndConvertDate"
       ├── Input: TextToConvert
       └── Output: ConversionResult, IsSuccess, ErrorMessage
    
    2. IF Statement: Check IsSuccess
       ├── IF True: Continue with ConversionResult
       └── IF False: Handle error using ErrorMessage

    Subflow: "ValidateAndConvertDate"

    1. Input Parameters:
       └── TextToConvert (Text)
    
    2. Set Variable: IsSuccess = False
    3. Set Variable: ConversionResult = ""
    4. Set Variable: ErrorMessage = ""
    
    5. Text Validation Logic:
       ├── Check format
       ├── Check ranges
       └── Check logical validity
    
    6. IF Valid:
       ├── Convert text to datetime
       ├── Set IsSuccess = True
       └── Set ConversionResult = converted value
    7. IF Invalid:
       ├── Set IsSuccess = False
       └── Set ErrorMessage = specific error
    
    8. Output Parameters:
       ├── ConversionResult
       ├── IsSuccess
       └── ErrorMessage

    Method 5: Text Parsing Alternative

    For Date Conversion Without Built-in Action:

    1. Extract Date Components:
       ├── Regular Expression: Extract year, month, day
       └── Store in separate variables
    
    2. Manual Date Construction:
       ├── Create date string in standard format
       └── Use string manipulation to build valid date
    
    3. Validation:
       ├── Check each component range
       └── Validate logical date (Feb 30th, etc.)
    
    4. Final Conversion:
       ├── Use validated components
       └── Convert to datetime format
     
    If I have answered your question, please mark it as the preferred solution ✅ . If you like my response, please give it a Thumbs Up 👍.
    Regards,
    Riyaz

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 519 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 296 Moderator

#3
abm abm Profile Picture

abm abm 232 Most Valuable Professional

Last 30 days Overall leaderboard