cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
PhilFancy
Advocate I
Advocate I

Split String to array(s) to fill Word template with repeating section

Hi everyone,

 

we have a SharePoint List with a multi line textfield "CUSTOMERS" that holds information in this pattern:

 

A GmbH; Temp Street; 32; 88975; Temp City; 2109999; Mr Miller; 0234-23422234; mail@mail.tld| BMX AG; BMX Street; 33; 60301; Berlin; 2108522; Mr. Welsh; +49 232 2211355; mail@test.tld |

 

You see information about 2 customers. They are separated by pipe (|). 

Every customer has 9 properties. They are separated by ;

 

Purpose is to split this information into small parts to fill a Word Template with repeated section and containing fields.

 

I can't find a way to split the values from the text field in such a way that I can use them to fill the fields contained in the repeated section in Word. 

Tried to use "initialize Variable" to create an Array variable. Then I do append to Array Variable with a split (

split(triggerOutputs()?['body/CUSTOMERS'],'|')) what always gives me a bad request as "AppendToArrayVariable" does only support "Float, Integer, String, Boolean or Object". But I do have a String here, don't I?
 
Any help to reach the goal to create a Word document with repeating section with this data is highly appreciated! 
 
Regards Phil
1 ACCEPTED SOLUTION

Accepted Solutions
tom_riha
Super User
Super User

Hello @PhilFancy ,

the result of the split(...) expression is always an array, that's why you see that error. Start with the split(...) expression to split the string into customers, the output will be an array with the customer values separated by ;. 

split(triggerOutputs()?['body/CUSTOMERS'],'|')

Then you should loop through that array and split the values for each customer. Add 'Apply to each' action, use the expression above as the input of the loop (you want to loop through the customers), and inside the loop split it again by ;.

split(item(),';')

The result will be an array with the 9 values, which you can easily reference by their index and use to fill out the Word document.

split(item(),';')[0]           the 1st value
split(item(),';')[1]           the 2nd value
split(item(),';')[2]           the 3rd value
...

 



[ If I have answered your question, please Accept the post as a solution. ]
[ If you like my response, please give it a Thumbs Up. ]

[ I also blog about Power Automate solutions even for non-IT people. ]

View solution in original post

1 REPLY 1
tom_riha
Super User
Super User

Hello @PhilFancy ,

the result of the split(...) expression is always an array, that's why you see that error. Start with the split(...) expression to split the string into customers, the output will be an array with the customer values separated by ;. 

split(triggerOutputs()?['body/CUSTOMERS'],'|')

Then you should loop through that array and split the values for each customer. Add 'Apply to each' action, use the expression above as the input of the loop (you want to loop through the customers), and inside the loop split it again by ;.

split(item(),';')

The result will be an array with the 9 values, which you can easily reference by their index and use to fill out the Word document.

split(item(),';')[0]           the 1st value
split(item(),';')[1]           the 2nd value
split(item(),';')[2]           the 3rd value
...

 



[ If I have answered your question, please Accept the post as a solution. ]
[ If you like my response, please give it a Thumbs Up. ]

[ I also blog about Power Automate solutions even for non-IT people. ]

Helpful resources

Announcements
 WHAT’S NEXT AT MICROSOFT IGNITE 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Register for a Free Workshop.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

September Events 2022

Check out all of these events

Attend in person or online, there are incredible conferences and events happening all throughout the month of September.

Users online (3,438)