cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
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
Super User
Super User

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

3 REPLIES 3
Super User
Super User

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

Administrator
Administrator

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
firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

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

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

SecondImage

Power Platform Summit North America

Register by September 5 to save $200

Top Kudoed Authors
Users Online
Currently online: 217 members 4,752 guests
Please welcome our newest community members: