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 / issues in Removeif and...
Power Apps
Answered

issues in Removeif and updatecontext

(0) ShareShare
ReportReport
Posted on by 2,249

I am facing issue on the below code as its not removing items properly from the current screen and please help

 

updatecontext({spinnersearch:true});

RemoveIf( Employee,Empid=Empid1);

If(

IsBlank(Lookup(Employee,Empid=Empid1)),

RemoveIf(Employee_Lookup,Eid=Empid1));

RemoveIf(Emp_dept_lo,Empid=Empid1);

RemoveIf(Attachments,Eid=Empid1);

ClearCollect(AttachmentID,Filter(Attached_docs,Eid=Empid1));

ForAll(AttachmentID,RemoveIf(Attached_docs,ID=AttachmentID[@ID]));

UpdateContext({Empdelete:false,spinnerLoad:false,Empid1:Blank(),vardept:false,Attachtab:false,regvisible:false,deptSearchNew:false});

Reset([@txtsearch]);UpdateContext({Spinnersearch:false})

Categories:
  • Verified answer
    RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @Veblitz 

    Please consider changing your Formula to the following:

    UpdateContext({Spinnersearch:true});
    
    RemoveIf(Employee, Empid=Empid1);
    If(!Lookup(Employee,Empid=Empid1, true), RemoveIf(Employee_Lookup,Eid=Empid1));
    
    RemoveIf(Emp_dept_lo,Empid=Empid1);
    RemoveIf(Attachments,Eid=Empid1);
    
    ForAll(Filter(Attached_docs,Eid=Empid1) As _item, RemoveIf(Attached_docs, ID=_item.ID));
    
    UpdateContext({Empdelete:false,spinnerLoad:false,Empid1:Blank(),vardept:false,Attachtab:false,regvisible:false,deptSearchNew:false});
    
    Reset(txtsearch);
    UpdateContext({Spinnersearch:false})

     

    I hope this is helpful for you.

  • Veblitz Profile Picture
    2,249 on at

    Thanks for your inputs.

    unfortunately,it is not working.

    I placed the above code in the yes button on select property,when i click on delete button it throws the popup in that yes or no will display so the above code is placed in yes button onselect and now button got freezed and no luck.Kindly help

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @Veblitz 

    I am not sure I am following what you mean by it froze.

    Are these collections or datasources that you are working with?  The suggested formula should work based on what you had, so I would need more details on the sources of the formula.

  • Veblitz Profile Picture
    2,249 on at

    Sure. when i click yes button there was no luck.i am using sharepoint list in the back end,

    these are collections . At UI level ,grouped 2 buttons for pop notification which has yes ,no button and the above code is placed inside the yes to perform the delete .

     

    Could you please help me to understand what was the issue with my above code that i shared and that was failing to delete properly?

     

    Kindly revert incase of any details.Thanks again

     

  • Veblitz Profile Picture
    2,249 on at

    Appreciate kind help.

    Further,i am newly working with powerapps apps design

  • Veblitz Profile Picture
    2,249 on at

    As per my above code its deleting properly on saving my apps

    when i try to test my code after publish apps its failing partially.

    it seems to be inconsistent before and after publish apps

     

    Appreciate kind help in this regards

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @Veblitz 

     

    If there is an inconsistence, then usually there is something that is converting incorrectly and improperly referenced in the Formula.

     

    Tell me about the items highlighted in the formula below:

     

    RemoveIf(Employee, Empid=Empid1);
    If(!Lookup(Employee,Empid=Empid1, true), RemoveIf(Employee_Lookup,Eid=Empid1));

    RemoveIf(Emp_dept_lo,Empid=Empid1);
    RemoveIf(Attachments,Eid=Empid1);

    ForAll(Filter(Attached_docs,Eid=Empid1) As _item, RemoveIf(Attached_docs, ID=_item.ID));

     

    For the RED - what are each of these?  Collections or your Datasource?  If collection, how are they defined and where are you adding or removing items to that collection in your app?

     

    For the Green - what, exactly, are those in your datasource?  Are they numeric or text?

     

    For the Blue - what is this and how is it defined?

  • Veblitz Profile Picture
    2,249 on at

    For the Red-datasource is sharepoint list

    For the Green- number field in the sharepoint list datasource

    For the Blue- variables defined in the section control

  • Veblitz Profile Picture
    2,249 on at

    For the blue: under the gallery control, Empid1 is declared as variable that binds the current selected empid and it defined as below in the app

     

    updatecontext({Empid1:Thisitem.Eid});

  • Veblitz Profile Picture
    2,249 on at

    After publish issue is associated with the below line of code,this section is not getting removed hence it performs only partial deletion 

    If(

    IsBlank(Lookup(Employee,Empid=Empid1)),

    RemoveIf(Employee_Lookup,Eid=Empid1));

     

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

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 382 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 329

#3
WarrenBelz Profile Picture

WarrenBelz 187 Most Valuable Professional

Last 30 days Overall leaderboard