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

Clearcollect using timer

My App is used on different devices and many users. Some of the devices (big Touch Screens) are always open for users to pass by and update records.

 

To keep alle devices (users) updated with the latest data, I'am using timers to refresh and clearcollect data from CDS (users "patch" updates using flows in many cases.

 

I have a really hard time to get clearcollect working. I have tried the tricks using 2 timers - one updating after the first one, making sure that all connections are refreshed and so forth.

 

But! - it's not really realiable! - screens are flashing and confusing users, and many times data are not updated until the third or forth time the timer has been triggered.

 

What is the best way to keep collections updated on the different devices? - I really need some input.

 

One of my timers looks like this:

 

If(
Showquickmenu = false;
UpdateContext({Starttimer2Update: false});;

Concurrent(
ClearCollect(Aureteborger; [@Borger]);

ClearCollect(
Nyborgercollection;
AddColumns(
Filter( Borgerregistrering;
crea5_companycode = AU_CID
And Opholdstype = Opholdkategori
And Afsluttet = 0
);
"onavn";'Oprettet af'.'Fulde navn';
"TranspBillede";
LookUp(
AureteTransport;
cr9eb_tranid = Value(Transportype);
Transportbillede
)
)
)

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted

Now it work's perfectly 🙂 - Thank you very much.

/Lars

 

If(
    Showquickmenu = false;
        UpdateContext({Starttimer2Update: false});;
Refresh(Borger);;Refresh(Borgerregistrering);;Refresh('2019Borgerdata');;Refresh(Rooms); Refresh(Kalenderbasis);
   Concurrent(
   
     ClearCollect(Aureteborger;
        ShowColumns(
            SortByColumns( 
                [@Borger];
                "crea5_primaryname";Ascending);
                "cr9eb_alder";
               
                "cr9eb_au_upds";
                "cr9eb_borgerfotony";
                "cr9eb_crea5_Borgerregistrering_crea5_Borger_cre";
                "crea5_adresse1";
                "crea5_adresse2";
                "crea5_adresse3";
                "crea5_aktiv";
                "crea5_borger_Annotations";
                "crea5_Borger_crea5_Borgerregistrering";
                "crea5_borgerid";
                "crea5_by";
                "crea5_companycode";
                "crea5_cprnummer";
                "crea5_email1";
                "crea5_email2";
                "crea5_firstname";
                "crea5_lastname";
                "crea5_middlename";
                "crea5_mobil";
                "crea5_notat1";
                "crea5_notat2";
                "crea5_postnummer";
                "crea5_primaryname";
                "crea5_secondname";
                "crea5_telefon";
                "createdby";
                "createdon";
                "entityimage";
                "entityimageid";
                "modifiedby"
        ));
      ClearCollect(
        Nyborgercollection;               
         AddColumns(
            ShowColumns(
                SortByColumns(          
                     Filter( Borgerregistrering;
                          crea5_companycode = AU_CID
                          And Opholdstype = Opholdkategori
                          And Afsluttet = 0
                            );
                            "crea5_primaryname";Ascending);
                            "cr9eb_ankomment";
                            "cr9eb_au_upds";
                            "cr9eb_BorgerforlobRelation";
                            "cr9eb_Borgermaal_cr9eb_Borger_crea5_Borge";
                            "cr9eb_brcounter";
                            "cr9eb_crea5_Borgerregistrering_crea5_Borger_cre";
                            "cr9eb_crea5_Borgerregistrering_crea5_Borgerregi";
                            "cr9eb_facebook";
                            "cr9eb_facebookny";
                            "cr9eb_foelges";
                            "cr9eb_henvisningsid";
                            "cr9eb_hjaelp1p";
                            "cr9eb_hjaelp2p";
                            "cr9eb_ilt";
                            "cr9eb_ingengeenoplivning";
                            "cr9eb_kaldtype";
                            "cr9eb_kateter";
                            "cr9eb_korttekst";
                            "cr9eb_ktype";
                            "cr9eb_liftes";
                            "cr9eb_omraade";
                            "cr9eb_sagsbehandler";
                            "cr9eb_sagsbehandler2";
                            "cr9eb_selvadministrernde";
                            "cr9eb_sondenasal";
                            "cr9eb_sondepeg";
                            "cr9eb_sygehus";
                            "cr9eb_terminal";
                            "cr9eb_triage";
                            "cr9eb_visesambulant";
                            "cr9eb_voreskald";
                            "crea5_afsluttet";
                            "crea5_antaldage";
                            "crea5_Borger";
                            "crea5_borgernavn";
                            "crea5_Borgerregistrering_crea5_Udskrivnin";
                            "crea5_borgerregistreringid";
                            "crea5_carve";
                            "crea5_companycode";
                            "crea5_gop";
                            "crea5_note1";
                            "crea5_note2";
                            "crea5_opholdstype";
                            "crea5_primaryname";
                            "crea5_room";
                            "crea5_selvhjulpen";
                            "crea5_selvmedicinering";
                            "crea5_slutdato";
                            "crea5_startdato";
                            "crea5_stue";
                            "crea5_transportype";
                            "crea5_udskrevetdato";
                            "crea5_udskrevettil";
                            "crea5_udskrevettilnavn";
                            "crea5_udskrivningsdato";
                            "crea5_visitationsenhed";
                            "createdby";
                            "createdon";
                            "modifiedby"
            );
            "onavn";'Oprettet af'.'Fulde navn';
            "TranspBillede";
               LookUp(
                   AureteTransport;
                     cr9eb_tranid  = Value(Transportype);
                        Transportbillede
                      )))        
;
    ClearCollect(
      Aurete2019Borgerdata;
      AddColumns(
          ShowColumns(
              SortByColumns(
                   Filter('2019Borgerdata';
                   Companycode = AU_CID);
                   "cr9eb_primaryname";Ascending);
                    "cr9eb_afsluttet";
                    "cr9eb_borger";
                    "cr9eb_Anvarlig";
                    "cr9eb_au_upds";
                    "cr9eb_Belastningsgrad";
                    "cr9eb_beskrivelse";
                    "cr9eb_borgerdataid";
                    "cr9eb_br2019counter";
                    "cr9eb_companycode";
                    "cr9eb_FS3Funktionsevnetilstand";
                    "cr9eb_FS3Helbredstilstand";
                    "cr9eb_kontroldato";
                    "cr9eb_opretter";
                    "cr9eb_oprettetafnavn";
                    "cr9eb_primaryname";
                    "cr9eb_registreringstypeid";
                    "cr9eb_Tilstandstype";
                    "createdby";
                    "createdon"
          )  ;
       "odnavn";'Oprettet af'.'Fulde navn'
      ));
    ClearCollect(AureteRooms;
             ShowColumns(
                 SortByColumns(            
                       Filter(Rooms; Companycode = AU_CID);
                       "crea5_primaryname"; Ascending);
                       "cr9eb_bedready";
                       "cr9eb_cleanroom";
                       "cr9eb_emptyroom";
                       "cr9eb_farvekode";
                       "cr9eb_ledig";
                       "cr9eb_m";
                       "cr9eb_roombackcolor";
                       "crea5_companycode";
                       "crea5_primaryname";
                       "crea5_roomsid";
                       "crea5_sortering";
                       "crea5_team"
             ))
             ;
                      
    ClearCollect(AureteKalenderbasis;
          ShowColumns(
              SortByColumns(
                  Filter(Kalenderbasis;
                     cr9eb_companycode = AU_CID
                     And cr9eb_arstal = "0" );
                     "cr9eb_borger";Ascending);
                     "cr9eb_afsluttet";
                     "cr9eb_aktivitet";
                     "cr9eb_Ansvarlig";
                     "cr9eb_arstal";
                     "cr9eb_borger";
                     "cr9eb_companycode";
                     "cr9eb_dato";
                     "cr9eb_kalenderbasisid";
                     "cr9eb_kalendertaeller";
                     "cr9eb_minut";
                     "cr9eb_note";
                     "cr9eb_opgansvarlig";
                     "cr9eb_primaryname";
                     "cr9eb_recurvalue";
                     "cr9eb_room";
                     "cr9eb_slutminut";
                     "cr9eb_sluttidspunkt";
                     "cr9eb_sluttime";
                     "cr9eb_sorteringrute";
                     "cr9eb_teammedarbejderid";
                     "cr9eb_tidstart";
                     "cr9eb_time";
                     "cr9eb_transporttype";
                     "cr9eb_type";
                     "cr9eb_uge";
                     "cr9eb_varighed";
                     "cr9eb_weekday";
                     "createdby";
                     "createdon";
                     "modifiedby"
          ))  )
)
 

View solution in original post

2 REPLIES 2
Highlighted
Community Support
Community Support

Hi @larshostrup ,

Do you want to keep the collection table with latest data from your CDS Entity?

 

Based on the needs that you mentioned, I think Timer control is a available solution for your scenario. I think single one Timer control could achieve your needs. 

Set the Duration property of the Timer control to following:

3000

Set the AutoStart and Repeat property of the Timer control to following:

true

Set the OnTimerEnd property of Timer control to following:

Refresh(Borger);;Refresh(Borgerregistrering);;
Concurrent(
           ClearCollect(Aureteborger; [@Borger]);
           ClearCollect(
                       Nyborgercollection;
                       AddColumns(
                                   Filter(
                                          Borgerregistrering;
                                          crea5_companycode = AU_CID;
                                          Opholdstype = Opholdkategori; 
                                          Afsluttet = 0
                                    );
                                    "onavn"; 'Oprettet af'.'Fulde navn';
                                  "TranspBillede";
                                  LookUp(AureteTransport;cr9eb_tranid = Value(Transportype);Transportbillede)
                     )
           )
)

 

In addition, as another solution, you could also consider fire a flow from your canvas app after updating records in your CDS Entity, then within the flow, pull latest records from your CDS Entity, then return the retrieved table records back to your app (using "Response" action).

Please check and see if the following blog or threads would help in your scenario:

https://powerapps.microsoft.com/en-us/blog/return-an-array-from-flow-to-powerapps-response-method/

https://powerusers.microsoft.com/t5/Building-Power-Apps/How-to-display-the-result-of-SQL-Server-on-p...

https://powerusers.microsoft.com/t5/Building-Power-Apps/Read-Excel-Stored-in-SharePoint/m-p/327925

 

Within your app, you could store the result returned from your flow into a collection using the following formula:

ClearCollect(LatestCollection, 'Flow Name'.Run())

 

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.
Highlighted

Now it work's perfectly 🙂 - Thank you very much.

/Lars

 

If(
    Showquickmenu = false;
        UpdateContext({Starttimer2Update: false});;
Refresh(Borger);;Refresh(Borgerregistrering);;Refresh('2019Borgerdata');;Refresh(Rooms); Refresh(Kalenderbasis);
   Concurrent(
   
     ClearCollect(Aureteborger;
        ShowColumns(
            SortByColumns( 
                [@Borger];
                "crea5_primaryname";Ascending);
                "cr9eb_alder";
               
                "cr9eb_au_upds";
                "cr9eb_borgerfotony";
                "cr9eb_crea5_Borgerregistrering_crea5_Borger_cre";
                "crea5_adresse1";
                "crea5_adresse2";
                "crea5_adresse3";
                "crea5_aktiv";
                "crea5_borger_Annotations";
                "crea5_Borger_crea5_Borgerregistrering";
                "crea5_borgerid";
                "crea5_by";
                "crea5_companycode";
                "crea5_cprnummer";
                "crea5_email1";
                "crea5_email2";
                "crea5_firstname";
                "crea5_lastname";
                "crea5_middlename";
                "crea5_mobil";
                "crea5_notat1";
                "crea5_notat2";
                "crea5_postnummer";
                "crea5_primaryname";
                "crea5_secondname";
                "crea5_telefon";
                "createdby";
                "createdon";
                "entityimage";
                "entityimageid";
                "modifiedby"
        ));
      ClearCollect(
        Nyborgercollection;               
         AddColumns(
            ShowColumns(
                SortByColumns(          
                     Filter( Borgerregistrering;
                          crea5_companycode = AU_CID
                          And Opholdstype = Opholdkategori
                          And Afsluttet = 0
                            );
                            "crea5_primaryname";Ascending);
                            "cr9eb_ankomment";
                            "cr9eb_au_upds";
                            "cr9eb_BorgerforlobRelation";
                            "cr9eb_Borgermaal_cr9eb_Borger_crea5_Borge";
                            "cr9eb_brcounter";
                            "cr9eb_crea5_Borgerregistrering_crea5_Borger_cre";
                            "cr9eb_crea5_Borgerregistrering_crea5_Borgerregi";
                            "cr9eb_facebook";
                            "cr9eb_facebookny";
                            "cr9eb_foelges";
                            "cr9eb_henvisningsid";
                            "cr9eb_hjaelp1p";
                            "cr9eb_hjaelp2p";
                            "cr9eb_ilt";
                            "cr9eb_ingengeenoplivning";
                            "cr9eb_kaldtype";
                            "cr9eb_kateter";
                            "cr9eb_korttekst";
                            "cr9eb_ktype";
                            "cr9eb_liftes";
                            "cr9eb_omraade";
                            "cr9eb_sagsbehandler";
                            "cr9eb_sagsbehandler2";
                            "cr9eb_selvadministrernde";
                            "cr9eb_sondenasal";
                            "cr9eb_sondepeg";
                            "cr9eb_sygehus";
                            "cr9eb_terminal";
                            "cr9eb_triage";
                            "cr9eb_visesambulant";
                            "cr9eb_voreskald";
                            "crea5_afsluttet";
                            "crea5_antaldage";
                            "crea5_Borger";
                            "crea5_borgernavn";
                            "crea5_Borgerregistrering_crea5_Udskrivnin";
                            "crea5_borgerregistreringid";
                            "crea5_carve";
                            "crea5_companycode";
                            "crea5_gop";
                            "crea5_note1";
                            "crea5_note2";
                            "crea5_opholdstype";
                            "crea5_primaryname";
                            "crea5_room";
                            "crea5_selvhjulpen";
                            "crea5_selvmedicinering";
                            "crea5_slutdato";
                            "crea5_startdato";
                            "crea5_stue";
                            "crea5_transportype";
                            "crea5_udskrevetdato";
                            "crea5_udskrevettil";
                            "crea5_udskrevettilnavn";
                            "crea5_udskrivningsdato";
                            "crea5_visitationsenhed";
                            "createdby";
                            "createdon";
                            "modifiedby"
            );
            "onavn";'Oprettet af'.'Fulde navn';
            "TranspBillede";
               LookUp(
                   AureteTransport;
                     cr9eb_tranid  = Value(Transportype);
                        Transportbillede
                      )))        
;
    ClearCollect(
      Aurete2019Borgerdata;
      AddColumns(
          ShowColumns(
              SortByColumns(
                   Filter('2019Borgerdata';
                   Companycode = AU_CID);
                   "cr9eb_primaryname";Ascending);
                    "cr9eb_afsluttet";
                    "cr9eb_borger";
                    "cr9eb_Anvarlig";
                    "cr9eb_au_upds";
                    "cr9eb_Belastningsgrad";
                    "cr9eb_beskrivelse";
                    "cr9eb_borgerdataid";
                    "cr9eb_br2019counter";
                    "cr9eb_companycode";
                    "cr9eb_FS3Funktionsevnetilstand";
                    "cr9eb_FS3Helbredstilstand";
                    "cr9eb_kontroldato";
                    "cr9eb_opretter";
                    "cr9eb_oprettetafnavn";
                    "cr9eb_primaryname";
                    "cr9eb_registreringstypeid";
                    "cr9eb_Tilstandstype";
                    "createdby";
                    "createdon"
          )  ;
       "odnavn";'Oprettet af'.'Fulde navn'
      ));
    ClearCollect(AureteRooms;
             ShowColumns(
                 SortByColumns(            
                       Filter(Rooms; Companycode = AU_CID);
                       "crea5_primaryname"; Ascending);
                       "cr9eb_bedready";
                       "cr9eb_cleanroom";
                       "cr9eb_emptyroom";
                       "cr9eb_farvekode";
                       "cr9eb_ledig";
                       "cr9eb_m";
                       "cr9eb_roombackcolor";
                       "crea5_companycode";
                       "crea5_primaryname";
                       "crea5_roomsid";
                       "crea5_sortering";
                       "crea5_team"
             ))
             ;
                      
    ClearCollect(AureteKalenderbasis;
          ShowColumns(
              SortByColumns(
                  Filter(Kalenderbasis;
                     cr9eb_companycode = AU_CID
                     And cr9eb_arstal = "0" );
                     "cr9eb_borger";Ascending);
                     "cr9eb_afsluttet";
                     "cr9eb_aktivitet";
                     "cr9eb_Ansvarlig";
                     "cr9eb_arstal";
                     "cr9eb_borger";
                     "cr9eb_companycode";
                     "cr9eb_dato";
                     "cr9eb_kalenderbasisid";
                     "cr9eb_kalendertaeller";
                     "cr9eb_minut";
                     "cr9eb_note";
                     "cr9eb_opgansvarlig";
                     "cr9eb_primaryname";
                     "cr9eb_recurvalue";
                     "cr9eb_room";
                     "cr9eb_slutminut";
                     "cr9eb_sluttidspunkt";
                     "cr9eb_sluttime";
                     "cr9eb_sorteringrute";
                     "cr9eb_teammedarbejderid";
                     "cr9eb_tidstart";
                     "cr9eb_time";
                     "cr9eb_transporttype";
                     "cr9eb_type";
                     "cr9eb_uge";
                     "cr9eb_varighed";
                     "cr9eb_weekday";
                     "createdby";
                     "createdon";
                     "modifiedby"
          ))  )
)
 

View solution in original post

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Community Highlights

Community Highlights

Check out the Power Platform Community Highlights

Top Solution Authors
Top Kudoed Authors
Users online (9,566)