web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Add delay to the code
Power Apps
Unanswered

Add delay to the code

(1) ShareShare
ReportReport
Posted on by 117

Hello there,

 

Context:

I have two local connections that I am patching when the phone gets internet.

first collection contains general information about a family. second collection contains information about the family's members.

during data collection I assign a serial number to each family and use the same one to its members.

 

to patch the colelctions to SharePoint, I go through a first ForAll loop and inside a go again to a second ForAll loop. 

 

my problem:

becuase the data in the first colelction is too much (around 70 columns) it seems that it's taking a bit of time to update the first SharePoint list which is resulting with wrong Serial Number assigned to the family members (the previous instead of the new)

 

my question:

can I add dealy to the code so I give SharePoint a second before patching the second collection

 

other suggestions are welcome, and here is a snippet of the code I am using

thanks,

Alaa

 

 

ForAll(
 LocalCAT, Patch(CAT, Defaults(CAT),
 {
 HHID: First(SortByColumns(CAT,"HHID",Descending)).HHID + 1,
 ... the rest of the fields (around a 70 fields)
 });
 ForAll(
 Filter(
 LocalHouseholdMembers,
 HHID = LocalCAT[@HHID]
 ),
 Patch(HouseholdMembers, Defaults(HouseholdMembers),
 {
 HHID: First(SortByColumns(CAT,"HHID",Descending )).HHID,
 ... the rest of the fields
 }
 )
 )

Categories:
I have the same question (0)
  • PaulD1 Profile Picture
    2,914 on at

    To create a delay, you can use a timer control, but I don't think that is going to help you with an embedded ForAll loop.

    If I can ask, why are you using an embedded ForAll? As you have already assigned your joining IDs within the App, you don't need to retrieve the SharePoint assigned ID or anything like that. Can you just:

    Collect(CAT, LocalCat);
    Collect(HouseholdMembers,LocalHouseholdMembers)

    It isn't 'transactional' so if writing to CAT succeeds and writing to HouseholdMembers fails half way through, you'll end up with some CAT records missing their children, but if you want that sort of control you really want to be using Azure SQL DB and stored procedures.

  • v-xida-msft Profile Picture
    on at

    Hi @Alaa-Alarori ,

    Could you please share a bit more about your scenario?

     

    Based on the formula you provided above, I could not find any syntax error with it. If you want to add a Delay logic to your formula, I afraid that there is no way to achieve your needs in PowerApps currently.

     

    On your side, please consider modify your formula as below:

     

    ForAll(
     LocalCAT, 
    Collect( /* <-- Using Collect function to submit your data into your SP Lists */
    CAT, { HHID: First(SortByColumns(CAT,"HHID",Descending)).HHID + 1, ... the rest of the fields (around a 70 fields) }
    ); ForAll( Filter( LocalHouseholdMembers, HHID = LocalCAT[@HHID] ), Collect(
    HouseholdMembers, { HHID: First(SortByColumns(CAT,"HHID",Descending )).HHID, ... the rest of the fields } ) )
    )

     

    Or you could consider modify your formula as below:

    ClearCollect(
     SavedCATRecords,
     ForAll(
     LocalCAT, 
     Patch(
     CAT, 
     Defaults(CAT),
     {
     HHID: First(SortByColumns(CAT,"HHID",Descending)).HHID + 1,
     ... the rest of the fields (around a 70 fields)
     }
     )
     )
    );
    ForAll(
    SortByColumns(SavedCATRecords, "HHID", Descending), ForAll( LocalCAT, ForAll( Filter(LocalHouseholdMembers, HHID = LocalCAT[@HHID]), Patch( HouseholdMembers, Defaults(HouseholdMembers), { HHID: SavedCATRecords[@HHID], ... the rest of the fields } ) ) )
    )

    Please consider take a try with above solution, then check if the issue is solved. Also please consider use the Collect function to patch data into your SP list instead of the Patch function.

     

    Best regards,

     

  • Community Power Platform Member Profile Picture
    on at

    Hi @Alaa-Alarori how are you progressing with this? Were the above replies helpful?

     

    @Anonymous 

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 765 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 272

Last 30 days Overall leaderboard