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

ForAll Split String to Collection returns only one row t theo collection

My goal for this is that the gallery shows you this default value, then you update as needed and it will patch it to the collection, then concat it to a string and push to the column. This part works well, took me a while to get the updating done but it works. It's the loading back into the gallery that's causing me a whole world of pain. For some reason, it will split the string as required but only push out one value to the collection. I've tried moving the Clear Collect to inside the forAll and vice versa but nothing seems to work. I've been stuck on this for about a month now.

 

This is default value In the column as well as the value that gets patched and concatenated into a string.

 

 

2.0 cubic foot box - small|0|2.9|0|0$4.0 cubic foot box - large||4.9|0|0$Wardrobe tall box||23.5|0|0$Large Mirror/Picture||14|0|0$Small Mirror/Picture||39|0|0$Single/Full Mattress Bag||7.5|0|0$Queen Mattress Bag||10|0|0$King Mattress Bag||14|0|0$Sofa Plastic Cover||10|0|0$Chair Plastic Cover||9|0|0$Shrink Wrap||37.5|0|0$Bubble Wrap||45|0|0$Tape||2|0|0$Packing Paper||45|0|0

 

 

 

This is my function.

 

 

ClearCollect(
    packMatList,
    ForAll(
        Split(
            selectedItem.'Packing Materials List',
            "$"
        ),
        {
            item: Last(FirstN(Split(Result, "|").Result, 1).Result).Result,
            quantity: Value(Last(FirstN(Split(Result, "|").Result, 2).Result).Result),
            unitPrice: Value(Last(FirstN(Split(Result, "|").Result, 3).Result).Result),
            discount:Value(Last(FirstN(Split(Result, "|").Result, 4).Result).Result),
            total: Value(Last(Split(Result, "|").Result).Result)
        }
    )
);

 

 

Screenshot (213).png

What it should look like VS. What it looks like

Screenshot (215).pngScreenshot (216).png

1 ACCEPTED SOLUTION

Accepted Solutions
Anonymous
Not applicable

I found the issue, the quantity fields were Blank() so it didn't update properly

View solution in original post

7 REPLIES 7
Super User
Super User

@Anonymous 
I just tested your code and it worked for me. What I did was set a variable to your string, ie

Set(
    vTestStr,
    "2.0 cubic foot box - small|0|2.9|0|0$4.0 cubic foot box - large||4.9|0|0$Wardrobe tall box||23.5|0|0$Large Mirror/Picture||14|0|0$Small Mirror/Picture||39|0|0$Single/Full Mattress Bag||7.5|0|0$Queen Mattress Bag||10|0|0$King Mattress Bag||14|0|0$Sofa Plastic Cover||10|0|0$Chair Plastic Cover||9|0|0$Shrink Wrap||37.5|0|0$Bubble Wrap||45|0|0$Tape||2|0|0$Packing Paper||45|0|0"
)

then, ran your code using this variable, ie

ClearCollect(
    packMatList,
    ForAll(
        Split(
            vTestStr,
            "$"
        ),
        {
            item: Last(FirstN(Split(Result, "|").Result, 1).Result).Result,
            quantity: Value(Last(FirstN(Split(Result, "|").Result, 2).Result).Result),
            unitPrice: Value(Last(FirstN(Split(Result, "|").Result, 3).Result).Result),
            discount:Value(Last(FirstN(Split(Result, "|").Result, 4).Result).Result),
            total: Value(Last(Split(Result, "|").Result).Result)
        }
    )
);

 

And get a full collection:

packMatList.jpg

So not sure what's happening at your end? My guess is that you data isn't being recognised as a String. Maybe try setting it to a variable like I do and try again?

 

Anonymous
Not applicable

I tried your solution and sadly it didn't work outside the Power Apps environment. Everything works smoothly inside Power Apps but once I test it on Share Point, it fails.

@Anonymous 

So, are you wanting to embed this app into your SP site and run it from the site? 

 

If this isn't the case, then I'd say you have a Data Type mismatch somewhere and the first place to look would be the column type you are sending data to.

Anonymous
Not applicable

I found the issue, the quantity fields were Blank() so it didn't update properly

View solution in original post

@Anonymous 
So have you sorted your own issue? If so, make your answer as the solution and if possible provide some details about your solution. This will just help future, similar searches by other PA users.

Community Support
Community Support

Hi @Anonymous ,

Have you solved your problem?

 

Based on the formula that you mentioned, I have made a test on my side, and don't have the issue that you mentioned. Please also consider try the following formula:

ForAll(
       Split(
            selectedItem.'Packing Materials List',
            "$"
        ),
        Collect(
                packMatList,
                {
                 item: Last(FirstN(Split(Result, "|"), 1)).Result,
                 quantity: Value(Last(FirstN(Split(Result, "|"), 2)).Result),
                 unitPrice: Value(Last(FirstN(Split(Result, "|"), 3)).Result),
                 discount:Value(Last(FirstN(Split(Result, "|"), 4)).Result),
                 total: Value(Last(Split(Result, "|")).Result)
               }
        )
)

 

When you concatenate column values from your collection into a string value, you should add a If function to detect if the Quantity is blank, if true, concatenate 0 into the string rather than Blank value. The Concatenate formula may look like below:

Concat(
       CollectionTable,
       item & "|" & If(IsBlank(quantity), 0, quantity) & "|" & unitPrice & "|" & discount & "|" & total & "$"
)

 

If you have solved your problem, please consider go ahead to click "Accept as Solution" to identify this thread has been solved.

 

Best regards,

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

Thank you. I will be adopting the validation for the quality column into my solution.

Helpful resources

Announcements
New Badges

New Solution Badges!

Check out our new profile badges recognizing authored solutions!

New Power Super Users

Congratulations!

We are excited to announce the Power Apps Super Users!

Power Apps Community Call

Power Apps Community Call: February

Did you miss the call? Check out the Power Apps Community Call here.

Microsoft Ignite

Microsoft Ignite

Join digitally, March 2–4, 2021 to explore new tech that's ready to implement. Experience the keynote in mixed reality through AltspaceVR!

Top Solution Authors
Top Kudoed Authors
Users online (17,963)