cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Anonymous
Not applicable

Parsing a string

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

 

2 ACCEPTED SOLUTIONS

Accepted Solutions
Highlighted
Community Support
Community Support

Re: Parsing a string

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;

 

  • Use split() function to separate the events into single event and configure Apply to each to traverse each event.
split(triggerBody()['text'],';')
  • Configure Condition to exclude the last empty element in the array.
  • Use split() function again to separate the properties in a single event.

Split:

split(items('Apply_to_each'),',')
  • Use the array index to get the property value of the event separately.

Title:

outputs('Split')[0]

Start Time:

outputs('Split')[1]

End Time:

outputs('Split')[2]
  • Finally, these properties are configured in Create event action.

Image reference:

12.PNG13.PNG16.PNG

Hope it helps.

 

Best Regards,

Community Support Team _ Barry
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Highlighted
Skilled Sharer
Skilled Sharer

Re: Parsing a string

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

View solution in original post

2 REPLIES 2
Highlighted
Community Support
Community Support

Re: Parsing a string

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;

 

  • Use split() function to separate the events into single event and configure Apply to each to traverse each event.
split(triggerBody()['text'],';')
  • Configure Condition to exclude the last empty element in the array.
  • Use split() function again to separate the properties in a single event.

Split:

split(items('Apply_to_each'),',')
  • Use the array index to get the property value of the event separately.

Title:

outputs('Split')[0]

Start Time:

outputs('Split')[1]

End Time:

outputs('Split')[2]
  • Finally, these properties are configured in Create event action.

Image reference:

12.PNG13.PNG16.PNG

Hope it helps.

 

Best Regards,

Community Support Team _ Barry
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Highlighted
Skilled Sharer
Skilled Sharer

Re: Parsing a string

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

View solution in original post

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

Tech Marathon

Maratón de Soluciones de Negocio Microsoft

Una semana de contenido con +100 sesiones educativas, consultorios, +10 workshops Premium, Hackaton, EXPO, Networking Hall y mucho más!

Users online (5,156)