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

PowerApps Save CustomerData locally per Customer

Hello everybody.

 

I am trying to create an app with offline capability to see data for different customers.

For that I first create a collection with all my customers and there unique ACCOUNTNUM.

Next I want to create a savefile for each customer with there data by pressing a button.

I saw that you can use the command SaveData(Collection, Savename) and LoadData(Collection, SaveName).

My goal is to later be able to only load the data of that customer.

My Button.OnSelect looks atm like this:

    ClearCollect(
        DebitorenSammlung;
        GroupBy(
            Search(
                Filter(
                    '[dbo].[CUSTTABLEVIEW]';
                    DATAAREAID = DataAreaIDVar
                );
                UserEmailVar;
                "AVA_SALEREMAIL"
            );
            "ACCOUNTNUM";
            "NAME";
            "NAMEALIAS";
            "PRIMARYADDRESSCITY";
            "CLSFilGal1"
        )
    );;
    SaveData(
        DebitorenSammlung;
        "DebitorenSaveData"
    );;
    Clear(PerMonthSammlung);;
    ForAll(
        DebitorenSammlung;
        Collect(
            PerMonthSammlung;
            Filter(
                '[dbo].[CUSTINVOICEPERMONTHPOWERAPP]';
                DATAAREAID = DataAreaIDVar;
                INVOICEYEARINT >= DateYearPast2;
                ORDERACCOUNT = ACCOUNTNUM;
                UserEmailVar in AVA_SALEREMAIL
            )
        );;
        SaveData(
            PerMonthSammlung;
            Concatenate(
                "Month";
                ACCOUNTNUM
            )
        )

DataAreaIdVar and DateYearPast2 are previously set variables.

 

The problem is, that the collection doesn't get cleared each round and as such the data gets bigger and bigger with each new customer.

Am I doing sth wrong, and if so how can I fix it.

 

Best regards

Thimo Findeisen

2 REPLIES 2
Highlighted
Community Support
Community Support

Re: PowerApps Save CustomerData locally per Customer

So based on my understanding, the part that didn't work as expected is caused by the following part:

ForAll(
        DebitorenSammlung;
        Collect(
            PerMonthSammlung;
            Filter(
                '[dbo].[CUSTINVOICEPERMONTHPOWERAPP]';
                DATAAREAID = DataAreaIDVar;
                INVOICEYEARINT >= DateYearPast2;
                ORDERACCOUNT = ACCOUNTNUM;
                UserEmailVar in AVA_SALEREMAIL
            )
        );;

Please take a try to change the formula as below:

ForAll(
        DebitorenSammlung;
        Collect(
            PerMonthSammlung;
            Clearcollect(Filter(
                '[dbo].[CUSTINVOICEPERMONTHPOWERAPP]';
                DATAAREAID = DataAreaIDVar;
                INVOICEYEARINT >= DateYearPast2;
                ORDERACCOUNT = ACCOUNTNUM;
                UserEmailVar in AVA_SALEREMAIL
              )
) );;

 

See if that helps.

 

Regards,

Michael

Community Support Team _ Michael Shao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Highlighted
Frequent Visitor

Re: PowerApps Save CustomerData locally per Customer

Hello v-micsh-msft,

thank you for your answer.

 

While you are correct, that this would normally clear the collection, PowerApps tells me that the Clear function can not be used in the ForAll function.

Is there another way to clear a collection within ForAll?

 

Regards

Thimo

Helpful resources

Announcements
Ignite

Microsoft Ignite

This will be a conference that you do not want to miss!

secondImage

New Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.

August 2020 CYST Challenge

Check out the winners of the recent 'Can You Solve These?' community challenge!

Experience what’s next for Power Apps

Join us for an in-depth look at the new Power Apps features and capabilities at the free Microsoft Business Applications Launch Event.

Check this Out

Helpful information

Featuring samples like Return to the Workplace and Emergency Response Applications

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (3,956)