cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
mbelvadi
Regular Visitor

Need help fixing user input from form to create ISO8601 time

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!

1 ACCEPTED SOLUTION

Accepted Solutions
eric-cheng
Solution Sage
Solution Sage

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

 

 

 

View solution in original post

1 REPLY 1
eric-cheng
Solution Sage
Solution Sage

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

 

 

 

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

New Ideas Forum MPA.jpg

A new place to submit your Ideas for Power Automate

Announcing a new way to share your feedback with the Power Automate Team.

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

MPA Licensing.jpg

Ask your licensing questions at the Power Automate AMA!

Join Priya Kodukula and the licensing team, super users and MVPs to find answers to your questions on Power Automate licensing.

Users online (1,890)