cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
PhilFancy
Frequent Visitor

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 II
Super User II

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 II
Super User II

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

Helpful resources

Announcements
MPA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Top Solution Authors
Users online (1,942)