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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / 'Split' and 'Apply to ...
Power Automate
Answered

'Split' and 'Apply to Each'

(0) ShareShare
ReportReport
Posted on by 15

Hello Everyone,

I am attempting to have Flows read and email and then add a Calendar event. I have (finally) got it to work......

the next step is if the email has multiple entries. I want flows to add each entry into the calendar. my data is: 

=====================

Subject: (*CaseName) <Event>, <Date> @ <Time>, <Color>
Event: <Event>
Date: <Date>
Time: <Time>
Duration: <Duration>
Department: <Dept>
Location: <Location>
Notes: <Notes>
<EndEvent>

=========================

 

so the above (between the ===========) would be duplicated x number of times.

i tried the split command 

     split(body('Html_to_text'), 'Subject:')

and then the Apply to each command

     

but it only adds the first data set to the calendar.

 

Help please?

Thanks.

 

 

 

Categories:
I have the same question (0)
  • efialttes Profile Picture
    14,756 on at
    Hi!
    Can you inspect your "body('Html_to_text')" output, at least the section you want to iterate through? I guess there must be an unnoticed character in the pattern you want to find, so this explains you just get a single element in your split() output array

    In case you do not find the missing character, feel free to share the outputs in this same thread
    Hope this make sense
  • Patrick_B Profile Picture
    15 on at

    the output is below between the =======================

     

    Trigger (new email)

    Html to text (output)

    ==============================================

    Subject: (Testing) MSJ, 4/24/20 @ 10am, Court Appearance

    Event: MSJ

    Date: 4/24/20

    Time: 10:00 am

    Duration: 60

    Department: L-25

    Location: CR-1

    Notes: I really hope this works!

    <EndEvent>

     

    Subject: (Testing) MSJ, 4/24/20 @ 10am, Court Appearance

    Event: MSJ

    Date: 4/24/20

    Time: 12:00 pm

    Duration: 90

    Department: a-25

    Location: CR-1

    Notes: I really hope this works!

    <EndEvent>

    =============================================

     

    Compose (Apply to Each)

     

     

    [
     "",
     " (Testing) MSJ, 4/24/20 @ 10am, Court Appearance\n\nEvent: MSJ\n\nDate: 4/24/20\n\nTime: 10:00 am\n\nDuration: 60\n\nDepartment: L-25\n\nLocation: CR-1\n\nNotes: I really hope this works!\n\n<EndEvent>\n\n\n\n",
     " (Testing) MSJ, 4/24/20 @ 10am, Court Appearance\n\nEvent: MSJ\n\nDate: 4/24/20\n\nTime: 12:00 pm\n\nDuration: 90\n\nDepartment: a-25\n\nLocation: CR-1\n\nNotes: I really hope this works!\n\n<EndEvent>"
    ]

     

     

    then all the steps to do on each section.

    I note that there is 3 sections with the first being just a "", entry. there is only 2 actual sections. maybe it grabs the actual "Subject:" from the email subject line????

     

    thanks for the help.

     

     

  • efialttes Profile Picture
    14,756 on at

    Hi!

    Then, some good news there! split() is providing both events to 'Apply to each' right?

    I was expecting a first element in the array not containing any event. THe reason is, split searches for the delimiter, so if this delimiter is at the beginning of the string, an empty element is added.

    You can get rid of it either by:

    -using a 'Filter Array' action block so you assign join() expression as its input and define with the following condition...

    TErm on the left (expression): empty(item())
    Operator: equals
    Term on the right (expression): false

    ...and assign 'Filter Array' output as 'Apply to Each' input or,

    -by using the follwoing expression...

    skip(split(...),1)

    ... just replace the three dots with your split current input parameters.

     

    Hope this helps

     

  • Patrick_B Profile Picture
    15 on at

    Okay, changed my split command to:

     

    skip(split(body('Html_to_text'), 'Subject:'), 1)
     
    Since it only added one event to the calendar (instead of 2), i did something wrong still. 
    although, it only shows two events now, instead of 3.
     
    getting closer!
     
    Patrick Brewerimage.png
  • v-bacao-msft Profile Picture
    on at

     

    Hi @Patrick_B ,

     

    The sample data only contains two events.

     

    Best Regards,

  • Verified answer
    Patrick_B Profile Picture
    15 on at

    Howdy,

    thanks for replying.

    I finally figured it out......i am used to line item type of "coding".......

    this graphical solution seems cumberson. But after looking at example after example i noticed something a bit peculiar. 

    The "apply to each" box was a little bigger than the ones below it and were the same size as the boxes (steps) above. 

    Finally, i actually tried to move the boxes below it "into" the "Apply to Each"......what a dunce.........

    Once I moved them all to be encapsulated by the "apply to each" it was able to do all of the iterations required.

     

    It now works!!

    Thanks for replying.

     

    My current (last) step in my project is to send the email to invoke the Flow.

    I can get it to create the email but not paste the "Graphical Copy".....i have another workaround, but I think I cannot put a graphical paste in the "dos" command; or auto send that.....

     

    Appexecute("mailto:"+vAddress+"&subject="+vSubject + "&Line&Body="+vbody)

     

    I have to "paste" after the above command and then "send".

     

    Thanks again for your help.

     

  • efialttes Profile Picture
    14,756 on at

    So, you managed to overcome the first challenge, right?

    Congrats!

     

    Next steps? My humble suggestion is:

    1.-Mark this topic as "Solved" by clicking "Accept as a solution". THis way others with the same problem can find a solution faster. Please also note you can even select several responses as solution, even from different community members!

     

    Flow_AcceptSolution.png

     

    2.- Open a new thread for your next question, following the policy: 'One Question, one post'. This way you have more chances to attrack attention for superusers that are seeking for unanswered topics.

     

     

    Thanx for your help making this community great!

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 503 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 321 Moderator

#3
abm abm Profile Picture

abm abm 237 Most Valuable Professional

Last 30 days Overall leaderboard