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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / PowerApps functions ar...
Power Apps
Unanswered

PowerApps functions are not running sequentially

(0) ShareShare
ReportReport
Posted on by 6

Multiple formulas are written in the "onSuccess" event of the form.

1. Remove (DataSource,Condition)

2. ForAll(Collection,Patch(DataSource,Default,Record))

 

Sometimes records are removed from the DataSource and New records are inserted using the collection 

 

But it's not working as expected. It's removing the records only. Seems like it's inserting the record and then removing the record based on the condition.

 

Is there any way to sequence the order of processing?

Categories:
  • iAm_ManCat Profile Picture
    18,256 Most Valuable Professional on at

    Hey @YuvarajT 

     

    You are using Remove rather than RemoveIf - Remove does remove collections but doesn't use conditions whereas RemoveIf uses conditions rather than collections

    .. and can you provide the actual code you are using for the ForAll, exactly as you have it in your app? Rename the datasource if you need to for security reasons, but the actual code is critical to see what the issue it

     

    Also, instead of using Record, you should be Using ThisRecord, which will apply to the record being used in that particular iteration of the ForAll:

     

    RemoveIf(DataSource,Condition);
    ForAll(Collection,Patch(DataSourceName,Defaults(DatasourceName),ThisRecord))

     

  • AJ_Z Profile Picture
    3,711 Super User 2024 Season 1 on at

    Are you able to share the code/functions that are in this onsuccess so we can have a look 🙂

  • YuvarajT Profile Picture
    6 on at

    Sorry I was using RemoveIf only

    Code Sample:

    RemoveIf('Details','No'= textbox.Text);

    ForAll(ColDetails,Patch('Details',Default('Details'),{'No'=textbox.Text}));

  • YuvarajT Profile Picture
    6 on at

    Code Sample:

    RemoveIf('Details','No'= textbox.Text);

    ForAll(ColDetails,Patch('Details',Default('Details'),{'No'=textbox.Text}));

  • iAm_ManCat Profile Picture
    18,256 Most Valuable Professional on at

    Ok, so the problem to me looks like you are just patching new records with the 'No' field (I assume you have a 'No' field in your datasource),

     

    So what about all of the other fields? how will you identify which ColDetails it is if you are only patching the one field - you should include the others or some kind of reference (If you could provide some of the other fields in your ColDetails and your 'Details' list, that would help a lot 🙂 )

    //Remove ALL records from datasource where 'No' field equsl textbox contents
    RemoveIf('Details','No'= textbox.Text);
    //For All rows in ColDetails, Patch the Details datasource to create a new row with just one field filled, 'No', and no other fields.
    ForAll(ColDetails,
     Patch('Details',
     //Create new
     Default('Details'),
     {
     //Fill in no other fields, only 'No' when creating new item
     'No'=textbox.Text
     }
     )
    );

     

     

    It would help if you gave a bit more context - what are you trying to do with that patch? Your form will have submitted to the datasource - are you trying to create new blank items with only the 'No' field filled after that or what is the intention?

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 393 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 328

#3
WarrenBelz Profile Picture

WarrenBelz 278 Most Valuable Professional

Last 30 days Overall leaderboard