cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
dBrand
Resolver I
Resolver I

Unable to delete SQL Record

I am having an issue trying to remove a record from a SQL table from a canvas app (the records are all in a gallery, loaded from a SQL view). The TrxID is the primary key on the table. It works sometimes and not others, so my guess it is related to RemoveIf not being delegatable? My command is:

 

RemoveIf(Transactions As T, T.TrxID = RecID)

 

Since I read that RemoveIf is not delegatable, I went to use:

Remove(ARR_Transactions,ThisItem);   

but I get the errors:

The function 'Remove' has some invalid arguments.

Incompatible type. The collection cannot contain values of this type.

 

I don't see what is wrong with this. Am I missing something? I'm lost.

Thanks for any help!

 

1 ACCEPTED SOLUTION

Accepted Solutions
Jeff_Thorpe
Super User
Super User

I am assuming that ThisItem is returning the record for the view and not the table and that is what is causing the problem.

 

To fix that you need to do a lookup to find the record.

Remove(Transactions, Lookup(Transactions As T, T.TrxID = ThisItem.TrxID));

 

The lookup may need to be tweak because I am sure what the record format looks like.



--------------------------------------------------------------------------------
If this post helps answer your question, please click on “Accept as Solution” to help other members find it more quickly. If you thought this post was helpful, please give it a Thumbs Up.

View solution in original post

6 REPLIES 6
Jeff_Thorpe
Super User
Super User

In data source is different between the two examples. Is "ARR_Transactions" a table or view?



--------------------------------------------------------------------------------
If this post helps answer your question, please click on “Accept as Solution” to help other members find it more quickly. If you thought this post was helpful, please give it a Thumbs Up.

Sorry for the confusion. I mistyped the name, they are both Transactions and is a table. But the Gallery i sloaded from a View.

 

RemoveIf(Transactions As T, T.TrxID = RecID)

Remove(ARR_Transactions,ThisItem);  ---> Remove(Transactions,ThisItem);  

jcfDaniel
Super User
Super User

That Remove is in an OnSelect of a control, right? Is that control inside the gallery?


Regards. JD.

Yes to both.

Jeff_Thorpe
Super User
Super User

I am assuming that ThisItem is returning the record for the view and not the table and that is what is causing the problem.

 

To fix that you need to do a lookup to find the record.

Remove(Transactions, Lookup(Transactions As T, T.TrxID = ThisItem.TrxID));

 

The lookup may need to be tweak because I am sure what the record format looks like.



--------------------------------------------------------------------------------
If this post helps answer your question, please click on “Accept as Solution” to help other members find it more quickly. If you thought this post was helpful, please give it a Thumbs Up.

Thanks, that worked perfectly. 

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (5,321)