Hi all,
Currently I have a very long string I pass into my Flow from PowerApps, and I am trying to parse the string. The string I pass in was originally a collection in PowerApps, consisting of different calendar events and its corresponding information (Title of event, start time, and end time). In the string, the columns (details per each event) are separated by commas, and the different rows (different events) are separated by a semi-colon.
Here is an example of how two events are concatenated and passed into Flow:
Attend Workshop,11/12/2019 1:30 PM, 11/12/2019 2:30 PM; Pick up kids, 1/12/2019 2:00 PM, 1/12/2019 3:00 PM;
My flow diagram is super long in order to execute everything I need, so I wont post a picture for your sake. However, I do have a variable that keeps track of the current position (ideally would get updated to the index after each comma/semi-colon), a variable holding the index of the comma/semi-colon, and variables holding the substrings.
I know I can use the indexOf() expression to find the first comma in the string. However, how would I re-write this, or use another expression, to then find the next comma in my string?
My goal is to parse the title, start time, and end time for each event, and upload to outlook calendar until all events have been added from the long string.
Thank you,
Kenzie
Solved! Go to Solution.
Hi @Anonymous ,
You can use WDL function to parse this data.
For example, the data obtained from PowerApps is the following. I use Input to input these data as an example.
Attend Workshop, 11/12/2019 1:30 PM, 11/12/2019 2:30 PM; Pick up kids, 1/12/2019 2:00 PM, 1/12/2019 3:00 PM;
split(triggerBody()['text'],';')
Split:
split(items('Apply_to_each'),',')
Title:
outputs('Split')[0]
Start Time:
outputs('Split')[1]
End Time:
outputs('Split')[2]
Image reference:
Hope it helps.
Best Regards,
Since you are passing this in from PowerApps you are probably in control of the string that gets passed over.
If I was you I would create your string as a JSON object. Yep, sorry, this just got a bit "technical" but it will save you a ton of pain if you can get your head around it.
Your event data would then look like this in PowerApps, which you would send to Flow.
[ { "title": "Attend Workshop", "starttime": "2019-12-11T13:30:00", "endtime": "2019-12-11T14:30:00" }, { "title": "Pick up kids", "starttime": "2019-12-01T14:00:00", "endtime": "2019-12-01T15:00:00" } ]
Now, in Flow you can use the Parse JSON Action, Paste in this sample JSON to have it generate a schema for you (by using that little link under the Parse JSON Schema text box.
Now, in your following Flow Actions you will be able to access the properties of your JSON objects (and do an Apply to Each on it) to make your life super easy.
Oh, I also changed your dates and times to a UTC format to make them a LOT easier to work with.
-Mark
Hi @Anonymous ,
You can use WDL function to parse this data.
For example, the data obtained from PowerApps is the following. I use Input to input these data as an example.
Attend Workshop, 11/12/2019 1:30 PM, 11/12/2019 2:30 PM; Pick up kids, 1/12/2019 2:00 PM, 1/12/2019 3:00 PM;
split(triggerBody()['text'],';')
Split:
split(items('Apply_to_each'),',')
Title:
outputs('Split')[0]
Start Time:
outputs('Split')[1]
End Time:
outputs('Split')[2]
Image reference:
Hope it helps.
Best Regards,
Since you are passing this in from PowerApps you are probably in control of the string that gets passed over.
If I was you I would create your string as a JSON object. Yep, sorry, this just got a bit "technical" but it will save you a ton of pain if you can get your head around it.
Your event data would then look like this in PowerApps, which you would send to Flow.
[ { "title": "Attend Workshop", "starttime": "2019-12-11T13:30:00", "endtime": "2019-12-11T14:30:00" }, { "title": "Pick up kids", "starttime": "2019-12-01T14:00:00", "endtime": "2019-12-01T15:00:00" } ]
Now, in Flow you can use the Parse JSON Action, Paste in this sample JSON to have it generate a schema for you (by using that little link under the Parse JSON Schema text box.
Now, in your following Flow Actions you will be able to access the properties of your JSON objects (and do an Apply to Each on it) to make your life super easy.
Oh, I also changed your dates and times to a UTC format to make them a LOT easier to work with.
-Mark
Hi @v-bacao-msft - thanks for your response above.
I have same requirement to parse a string and map the values on basis of indexes.
But, i am facing below error -
'Apply to each' is getting failed -
ActionFailed. An action failed. No dependent actions succeeded.
Error in Compose action -
InvalidTemplate. Unable to process template language expressions in action 'Compose' inputs at line '0' and column '0': 'The template language expression 'outputs('split')[1]' cannot be evaluated because array index '1' is outside bounds (0, 0) of array. Please see https://aka.ms/logicexpressions for usage details.'.
Appreciate your help to resolve this.
Learn to digitize and optimize business processes and connect all your applications to share data in real time.
Did you know that you could restore a deleted flow? Check out this helpful article.
Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.
User | Count |
---|---|
21 | |
18 | |
11 | |
11 | |
8 |
User | Count |
---|---|
31 | |
27 | |
26 | |
20 | |
16 |