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

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
Community Support Team
Community Support Team

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
T_Findeisen
Level: Powered On

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
thirdimage

Power Automate 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

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors (Last 30 Days)
Users online (6,018)