cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Chauc3r
Helper I
Helper I

Alternative to Appending Order Lines

So, I've got a flow that calls our ordering system API and then sticks that data into SP with each order becoming a SP item.

 

Each order normally has only 1 order line, but it can have lots of order lines. At the moment, I initialize a variable, then "Apply to Each"  order line and append the contents of each line to a variable called order contents with displays in SP as multi line text. The lines are an array within the order. 

 

This works fine, but because of the variable, I have to turn concurrency off on my Apply to Each's. This means that each flow can take up to 45 minutes to run when assessing the max 1000 orders at a time.

 

Can anyone think of any cunning alternatives to that variable? I could live with only capturing the first three order lines ever, but it would have to cope with situations where the number of order lines could be 1,2,3,4+. Any bright ideas?

 

1 ACCEPTED SOLUTION

Accepted Solutions

HI @Chauc3r 

 

I inserted your sample into a Compose and built the following:

DamoBird365_0-1631609950214.png

The map is based on a concatenation of both values to create an array and then in the compose I join them (all) with a <BR>.

 

Output is as follows:

DamoBird365_1-1631609986438.png

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Cheers,
Damien


P.S. take a look at my new blog here and like & subscribe to my YouTube Channel thanks 😉

 

View solution in original post

4 REPLIES 4
DamoBird365
Super User
Super User

Hi @Chauc3r 

 

Can you share some example json and your required output?  Often you can do these things with a select and maybe even a compose.  For example, take a look at the following: Solved: How to combine data from two different arrays? - Power Platform Community (microsoft.com)

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Cheers,
Damien


P.S. take a look at my new blog here and like & subscribe to my YouTube Channel thanks 😉

Hi @DamoBird365,

Brilliant - so, the JSON looks like this (With a bunch of irrelevant stuff stripped out):

 

 

        {
            "OrderNumber": "PO-00001703",
            "OrderDate": "/Date(1633302000000)/",
            "Comments": null,
            "PurchaseOrderLines": [
                {
                    "Guid": "d65d4f4a-8234-433d-9896-1b4a6629778d",
                    "LineNumber": 1,
                    "Product": {
                        "Guid": "9e667a9a-9092-4851-8278-562c6512cbb3",
                        "ProductCode": "JSFB",
                        "ProductDescription": "Jute Sack Firewood Bag"
                    },
                    "OrderQuantity": 28000.0000,
                    "Comments": null                    
                },
                {
                    "Guid": "bc4dd5dd-44f0-436b-b8f4-4a08c96d320c",
                    "LineNumber": 2,
                    "Product": {
                        "Guid": "ea79a53c-d5b8-46d6-85ba-272b8659f830",
                        "ProductCode": "JSPFB",
                        "ProductDescription": "Jute Sack Pizza Firewood Bag"
                    },
                    "OrderQuantity": 6000.0000,
                    "Comments": null
                 }
            ],
         },

 

 

 

The desired output is a string in the format:

 

 

OrderQuantity + ' ' + ProductCode + '<br>'

 

 

That repeats for however many Purchase Order Lines there are. So, for the example above, we get a string like this:

"28000 JSFB <br>6000 JSPFB <br>"

 

The vast majority of Purchase Order Lines have just 1 line, but others can have multiples.

 

Any help greatly appreciated!

HI @Chauc3r 

 

I inserted your sample into a Compose and built the following:

DamoBird365_0-1631609950214.png

The map is based on a concatenation of both values to create an array and then in the compose I join them (all) with a <BR>.

 

Output is as follows:

DamoBird365_1-1631609986438.png

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Cheers,
Damien


P.S. take a look at my new blog here and like & subscribe to my YouTube Channel thanks 😉

 

View solution in original post

Chauc3r
Helper I
Helper I

Amazing, thank you.

 

30 mins down to 1 min per flow!

Helpful resources

Announcements
Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

User Group Leader Meeting January 768x460.png

Calling all User Group Leaders!

Don't miss the User Group Leader meetings on January, 24th & 25th, 2022.

Users online (2,135)