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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / If response = "Lesson ...
Power Automate
Unanswered

If response = "Lesson 1" changing it to a start time and an end time.

(0) ShareShare
ReportReport
Posted on by 7

Hi,

 

I need help. I'm not a hard core coder and I don't want to make things more complicated than they need be.

 

I have set up a form for teachers to fill in when they want to reserve PCs for tests. In the form, they indicate wg=hich lesson hour they need the PCs for. So this means they select Lesson Hour 1, Lesson Hour 2, etc through to Lesson Hour 9. 

 

I'm trying to set up a flow that will create an event in an Outlook calender. The thing is, the lesson hours are not really 60 minutes long. And they don't necessarily start on the hour.  (For example, Lesson Hour 1 is from 08:20 till 09:05, Lesson Hour 2 is from 09:05 till 09:50.

 

How can I get the flow to do something like "if x = Lesson Hour 1, start time is 08:20 and end time is 09:05". And this way, when I set up the "Create Event" action, I can imput the correct start and finish times?

 

I feel that I need to use an array here, but my v=brain isn't exactly sure what to do. Can anyone help me?

 

Many thanks

 

 

Categories:
  • Pstork1 Profile Picture
    69,661 Most Valuable Professional on at

    Take a look at the Switch function. If and Switch functions - Power Platform | Microsoft Learn Using a Switch you could set a value for the Lesson Hour and then use the Switch to set the start and end times in a record. Then use the properties from that record when creating the event. Something like this

    //Teacher picks Lesson Hour 1 so varHour is set to "1"
    
    Switch(varHour, "1", Set(LessonTime, {Start: "08:20", End: "09:05"}), 
     "2", Set(LessonTime, {Start: "09:05", End: "09:50"}),
     "3" etc.
    
  • markjowen Profile Picture
    7 on at

    Many thanks! I've used the Switch as you have suggested.

    First I created two variables "Start" and "End"

    Then I created a Switch action on "Time" (from the dynamic content).

    Then I created a case for each Lesson Hour. Under each case, I set the Start variable and the End variable.

    (Do you know if, when I create an Event (in Outlook), it will be OK that the Start and End variables are text?)

     

    Unfortunately, I haven't been able to test this flow yet. Not sure if it is relevant, but I'm working at home (not directly on the school network). In a following action I have created an "Send an email V2" action with information returned from the form, but when I try to save the flow, Power Automate shows a message about Input Parameters being wrong. I need to sort that out before I can go further.

     

    However, once I have done that, I can save and test the flow. I'll let you know!

    2023-12-17 08_32_25-Lesuren - OneNote.png
  • Pstork1 Profile Picture
    69,661 Most Valuable Professional on at

    If the text form of the times causes an issue you can use formatDatetime() to format the output as needed.

  • markjowen Profile Picture
    7 on at

    Thank you! (again). I'll use that.

  • markjowen Profile Picture
    7 on at

    Hi again - it's been many months since I worked on this. Due to "everyday tasks" I didn't have a chance to get any further. But now, I'm back at it.

     

    So to recap, I get a "lesson hour" (e.g "lesson hour 1","Lesson Hour 2", etc) from a submitted form. II've initialized two string variables: "start_time" and "end_time" and then later in the flow I have a Switch action that checks submitted "Lesson Hour" and sets the start_time and end time variables to the actual start and end time of the lesson hour. This alls works fine 👍.

     

    What I want to do is set an action to create an event in Outlook. As it stands, this works (sort of). It sets the event for the correct date, but doesn't know what to do with the start_time variable and end_time variable. I think that this is because they are strings. I've been trying to work out how to convert the string into an actual time, but this is where I get lost. I started trying the Parse JSON function, but quickly got out of my depth 😣. Can anyone help me with this?🙏

  • jakesteele Profile Picture
    2 on at

    Hi,

    Take a look at the formatting of what needs to be submitted for "Start Time" and "End Time"

    jakesteele_0-1721128591489.png

    You can submit a string but it will need to be in the format of 'YYYY-MM-DDTHH:MM:SS'.

    If you want to see what formats are accepted please take a look here: Standard date and time format strings - .NET | Microsoft Learn

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
David_MA Profile Picture

David_MA 245 Super User 2026 Season 2

#2
11manish Profile Picture

11manish 233 Super User 2026 Season 2

#3
Valantis Profile Picture

Valantis 136 Super User 2026 Season 2

Last 30 days Overall leaderboard