Hi all,
I'm trying to set up a flow that when an MS Form is submitted it will automatically create an event in a agenda.
To get the start time (and end time) for the event I would like to get this from the answer that is submitted to a specific question (multiple choice).
Here are the multiple answers:
- Before 08:00
- Between 08:00 and 10:00
- Between 10:00 and 12:00
- ...
If would like to have that for example "Between 08:00 and 10:00" is selected, the start time of the event is 08:00 and the end time 10:00.
If "Before 08:00" is selecten, start time would be 06:00 and end time 08:00.
Hope someone can help.
Hi @Nico_BE,
In that case you can replace the utcNow part of the expression and use a parsedatetime and concat the two answers instead.
Below is an updated example
Question id re7c36c9651bb45de917e7e9032359e3f is the date question, question id r65022e71321749ebb83c2c4086df811a is the choice question with the time text options.
Start Time
parsedatetime(concat(outputs('Get_response_details')?['body/re7c36c9651bb45de917e7e9032359e3f'], 'T', if(startswith(outputs('Get_response_details')?['body/r65022e71321749ebb83c2c4086df811a'], 'Between'), split(skip(outputs('Get_response_details')?['body/r65022e71321749ebb83c2c4086df811a'], 8), ' and ')[0], if(startswith(outputs('Get_response_details')?['body/r65022e71321749ebb83c2c4086df811a'], 'Before'), '06:00','16:00')), ':00'), 'en-us', 'yyyy-MM-ddTHH:mm:ss')
End Time
parsedatetime(concat(outputs('Get_response_details')?['body/re7c36c9651bb45de917e7e9032359e3f'], 'T', if(startswith(outputs('Get_response_details')?['body/r65022e71321749ebb83c2c4086df811a'], 'Between'), split(skip(outputs('Get_response_details')?['body/r65022e71321749ebb83c2c4086df811a'], 8), ' and ')[1], if(startswith(outputs('Get_response_details')?['body/r65022e71321749ebb83c2c4086df811a'], 'Before'), '08:00','18:00')), ':00'), 'en-us', 'yyyy-MM-ddTHH:mm:ss')
Thanks for the reply, this has helped a lot but .... I forgot to mention that in the form they have to select a date also.
Could you please help so that the event wil be set on the given date + the answer for the given timeslot.
Hi @Nico_BE !
Do try this flow given below:
This event will be created in teams. I am using the current date.
The forms which I created what it looks like:
The condition which I am using is to check if it contains 'Before'. (You could also check if it contains 'Between'. Any will work.) The case which I am doing is checking if Before exists or not in that response.
So if yes, split the text say you got 'Before 08:00'. Split where there is space and get the 2nd text that is the time. In programming terms, it will be index 1 (as indexing starts from 0). So the expression used for Time Period action is:
split(outputs('Get_response_details')?['body/r497a8a9040de4fa088a6a21aeabf9ef8'],' ')[1]
In the case for the 'No' side, i.e. when it is 'Between', there will be two time periods.
Ex.: Between 10:00 and 12:00
Same expression for first one (since its at index 1) and other one just change the index to 3 (since its at index 3)
After this, do the conversion of time.
Time zone should be same since you are setting for universal people. Format string keep to Sortable date/time pattern.
Next use Add to time action. Since you need in 'Before' part to be -2 hours. This will give you Calculated time variable
Lastly, used a Create a teams meeting action to create an event of the same. Use the necessary variables in start time and end time. Since I didn't add a body to my forms, I kept it as 'None'.
Result:
It is success.
When selected Before:
When selected Between:
I hope this solves your question.
Hi @Nico_BE,
You could use a startswith and check with which characters the options start. If it is a Between you can use a split to retrieve the start and end times.
Below is an example
Start Time
utcNow(concat('yyyy-MM-ddT', if(startswith(outputs('Get_response_details')?['body/r65022e71321749ebb83c2c4086df811a'], 'Between'), split(skip(outputs('Get_response_details')?['body/r65022e71321749ebb83c2c4086df811a'], 8), ' and ')[0], if(startswith(outputs('Get_response_details')?['body/r65022e71321749ebb83c2c4086df811a'], 'Before'), '06:00','16:00')), ':00'))
End Time
utcNow(concat('yyyy-MM-ddT', if(startswith(outputs('Get_response_details')?['body/r65022e71321749ebb83c2c4086df811a'], 'Between'), split(skip(outputs('Get_response_details')?['body/r65022e71321749ebb83c2c4086df811a'], 8), ' and ')[1], if(startswith(outputs('Get_response_details')?['body/r65022e71321749ebb83c2c4086df811a'], 'Before'), '08:00','18:00')), ':00'))
Michael E. Gernaey
566
Super User 2025 Season 1
David_MA
516
Super User 2025 Season 1
stampcoin
492