Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Automate - Using Flows
Answered

Need help fixing user input from form to create ISO8601 time

(0) ShareShare
ReportReport
Posted on by 10

Hi, all. I have a Flow that takes input from a form and creates a calendar event.  But Microsoft Forms doesn't allow me to force the input of a time to be valid, and so my flow keeps breaking when my users input times as 0830 or 8:30 instead of 08:30. Right now all I have is to string together the date (from a date picker so that's always fine) plus the "T" plus the inputted time, plus a trailing ":00".

What I need is the logic to parse what they put in the "start time" and "end time" (short text) fields of the form to check if they forgot the colon or the leading zero to fix what they put in so I can hand it off to Convert Time Zone and continue my script from there.

I don't really know how to edit the raw code under Flows, so I need the instructions in steps that I can put into the Flow GUI editor. I could do this in python, but I have no idea how to do a nested series of IFs looking at string contents/substrings in Flow.

I'm picturing code that basically says (in old fashioned pseudocode style):

IF the string contains a colon AND is 5 characters long THEN its fine, continue

  ELSE IF the string is 4 characters long:

     IF the string contains a colon, THEN it must be missing the leading zero, so add it and continue

      ELSE the string must be missing the colon THEN stick it in the third position and continue

 ELSE (the string is neither 4 nor 5 characters long) THEN send an email to the user (I have their address from the form) telling them we failed to record this event

 

Alternatively, if there's just a way to do the python equivalent of "try" and catch IF the ConvertTimeZone is going to fail, just send that email warning them without trying to fix their bad input and make them resubmit the form, that would also be an acceptable outcome, if not quite as user-friendly.

 

I have a very small user group who I don't expect to do really stupid things like put in starting times that aren't times at all so I don't need to check for input like AB:CD, but they can sometimes make more reasonable input mistakes like I described above.

 

Thank you very much for any help you can provide!

  • Verified answer
    eric-cheng Profile Picture
    5,171 on at
    Re: Need help fixing user input from form to create ISO8601 time

    Hi @mbelvadi ,

     

    For the first part of your question.  You will probably need to use a series of expressions to do what you want.  It won't be pretty though.  The below is just an example. 

    ericcheng_1-1631071883557.png

    Alternatively, you can look to use Forms Premium / D365 Customer Voice.  It allows you to set a custom restriction using regular expressions to validate content.  There is a cost though but just putting it out there as an alternative.

     

    In regards to the 2nd part of your question, you can use scopes to implement try/catch/finally logic or use 'Configure Run After' in your action properties to ask it to run only after the previous action was successful or failed.   Please refer to this here.

     

    ericcheng_2-1631072099562.png

     

    --------------------------------------------------------------------------
    If I have answered your question, please mark my post as a solution
    If you have found my response helpful, please give it a thumbs up

    Connect on LinkedIn

     

     

     

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

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,702 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 66,015 Most Valuable Professional

Leaderboard

Featured topics

Restore a deleted flow