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 / Remove function takes ...
Power Apps
Answered

Remove function takes so much time to run

(0) ShareShare
ReportReport
Posted on by 33

 

Since the others table contains the foreign key, so I have to delete it first. But it takes too much time to complete the whole delete process. Can someone help me to optimize my code?

//remove foreign key
Set(InitialInjuredPerson_Activity,
 RemoveIf(
 InjuredPerson_Activity,
 InjuredPersonId = InjuredPersonDeleteID
 )
);

Set(InitialInjuredPerson_SuspectedInjured,
 RemoveIf(
 InjuredPerson_SuspectedInjured,
 InjuredPersonID = InjuredPersonDeleteID
 )
);

Set(InitialInjuredPerson_OngoingPlan,
 RemoveIf(
 InjuredPersion_OngoingPlan,
 InjuredPersonID = InjuredPersonDeleteID
 )
);

//remove main table
Set(InitialInjured_Person,
 RemoveIf(
 Injured_Person,
 InjuredPersonID = InjuredPersonDeleteID
 )
);

 

Categories:
I have the same question (0)
  • Verified answer
    BCBuizer Profile Picture
    22,844 Super User 2026 Season 2 on at

    Hi @asdadasdasdasss ,

     

    Have you tried the Concurrent function to perform these formulas in parallel? At first glance there doesn't seem to be a dependency between the four, so you can give this a try:

    Concurrent(
    	//remove foreign key
    	Set(InitialInjuredPerson_Activity,
    		RemoveIf(
    			InjuredPerson_Activity,
    			InjuredPersonId = InjuredPersonDeleteID
    		)
    	),
    
    	Set(InitialInjuredPerson_SuspectedInjured,
    		RemoveIf(
    			InjuredPerson_SuspectedInjured,
    			InjuredPersonID = InjuredPersonDeleteID
    		)
    	),
    
    	Set(InitialInjuredPerson_OngoingPlan,
    		RemoveIf(
    			InjuredPersion_OngoingPlan,
    			InjuredPersonID = InjuredPersonDeleteID
    		)
    	),
    
    	//remove main table
    	Set(InitialInjured_Person,
    		RemoveIf(
    			Injured_Person,
    			InjuredPersonID = InjuredPersonDeleteID
    		)
    	)
    )
  • asdadasdasdasss Profile Picture
    33 on at

    Thanks for your answer! I thought the concurrent only could use in On Start property. But I would like to ask you whether the code below will wait for the "concurrent" finishes and then proceed with the last code.

     

    Concurrent(
    	//remove foreign key
    	Set(InitialInjuredPerson_Activity,
    		RemoveIf(
    			InjuredPerson_Activity,
    			InjuredPersonId = InjuredPersonDeleteID
    		)
    	),
    
    	Set(InitialInjuredPerson_SuspectedInjured,
    		RemoveIf(
    			InjuredPerson_SuspectedInjured,
    			InjuredPersonID = InjuredPersonDeleteID
    		)
    	),
    
    	Set(InitialInjuredPerson_OngoingPlan,
    		RemoveIf(
    			InjuredPersion_OngoingPlan,
    			InjuredPersonID = InjuredPersonDeleteID
    		)
    	)
    )
    
    //remove main table
    Set(InitialInjured_Person,
    	RemoveIf(
    		Injured_Person,
    		InjuredPersonID = InjuredPersonDeleteID
    	)
    )

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
WarrenBelz Profile Picture

WarrenBelz 358 Most Valuable Professional

#2
11manish Profile Picture

11manish 214 Super User 2026 Season 2

#3
Mohsin Ali Profile Picture

Mohsin Ali 185

Last 30 days Overall leaderboard