cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
AJ13
Level: Powered On

Clear collection in ForAll

Hi,

 

I am creating an app that reads an excel and  appends records top an SP List in bulk. The list contains a multi-select person field as well. 

 

I am running a ForAll through all records in my collection (NewData), splitting the multiperson email field into another collection of emails ids (AllSPOC) and then patching the record to SPList ('Access Monitor')

 

ForAll(
    NewData,
    Collect(
        AllSPOC,
        Split(
            SPOCs,
            ";"
        )
    );
    Patch(
        'Access Monitor',
        Defaults('Access Monitor'),
        {
            SPOCs: ForAll(
                AllSPOC,
                {
                    Claims: Result,
                    Department: "",
                    DisplayName: "",
                    Email: "",
                    JobTitle: "",
                    Picture: ""
                }
            ),
        }
    )
)

My problem is that I need to clear the email id collection, AllSPOC (for the multiperson column) after patching each record in ForAll. But clear/clearcollect does not work within ForAll. 

 

Does anybody have any ideas on how to get around this?

 

Thanks in advance.

1 ACCEPTED SOLUTION

Accepted Solutions
Microsoft RusselThomas
Microsoft

Re: Clear collection in ForAll

Hi @AJ13 ,

 

My approach would be to try and run the Split in-line. 
It provides a table output, so you don't need to collect it and the output will reset each time it's run within the ForAll.
Try this;

 

ForAll(
    NewData,
    Patch(
        'Access Monitor',
        Defaults( 'Access Monitor'),
        {
            SPOCs: ForAll(
                Split(
                   NewData[@SPOCs],  //disambiguate as source column name appears same as destination column name
                    ";"
                ),
                {
                    Claims: Result,
                    Department: "",
                    DisplayName: "",
                    Email: "",
                    JobTitle: "",
                    Picture: ""
                }
            )
        }
    )
)

If your NewData column name isn't the same as your destination List column name you won't need the disambiguation.

 

Hope this helps,


RT

View solution in original post

3 REPLIES 3
Microsoft RusselThomas
Microsoft

Re: Clear collection in ForAll

Hi @AJ13 ,

 

My approach would be to try and run the Split in-line. 
It provides a table output, so you don't need to collect it and the output will reset each time it's run within the ForAll.
Try this;

 

ForAll(
    NewData,
    Patch(
        'Access Monitor',
        Defaults( 'Access Monitor'),
        {
            SPOCs: ForAll(
                Split(
                   NewData[@SPOCs],  //disambiguate as source column name appears same as destination column name
                    ";"
                ),
                {
                    Claims: Result,
                    Department: "",
                    DisplayName: "",
                    Email: "",
                    JobTitle: "",
                    Picture: ""
                }
            )
        }
    )
)

If your NewData column name isn't the same as your destination List column name you won't need the disambiguation.

 

Hope this helps,


RT

View solution in original post

TopShelf-MSFT
Level 10

Re: Clear collection in ForAll

Thanks for posting in the community @AJ13 - can you review the above reply and update the thread if it was helpful?

 

Thank you,

 

@TopShelf-MSFT 

AJ13
Level: Powered On

Re: Clear collection in ForAll

@RusselThomas Thank you for that solution. That solved my issue.

Helpful resources

Announcements
thirdimage

Coming Soon: T-Shirt Design Contest

Keep your eyes open for our upcoming T-shirt design contest!

thirdimage

Power Apps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

Top Solution Authors
Top Kudoed Authors
Users online (6,000)