cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Frequent Visitor

Delete a record in Azure SQL data table from PowerApp

Hello, 

I want to remove a record from the Azure SQL table when user clicks on the "Delete" icon from PowerApps.

I write this code for the OnSelect

 Remove('[dbo].[Input_Table]',LookUp('[dbo].[Input_Table]',Input_ID = BrowseGallery1.Selected.Input_ID));

the record is not deleted, and there is no error. How can I make the delete work for Azure DB table?

 

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Resolver I
Resolver I

Re: Delete a record in Azure SQL data table from PowerApp

Hi @lilyd99 ,

You shouldn't need the LookUp function in this case as you are looking up to the same table you are deleting from. So this should suffice: RemoveIf('[dbo].[Input_Table]', Input_ID = BrowseGallery1.Selected.Input_ID);

 

Thanks

 

EDIT: It should be a RemoveIf ONLY if the ID in your data souce is a unique field, otherwise it will delete everything with that ID

View solution in original post

7 REPLIES 7
Highlighted
Resolver I
Resolver I

Re: Delete a record in Azure SQL data table from PowerApp

Hi @lilyd99 ,

You shouldn't need the LookUp function in this case as you are looking up to the same table you are deleting from. So this should suffice: RemoveIf('[dbo].[Input_Table]', Input_ID = BrowseGallery1.Selected.Input_ID);

 

Thanks

 

EDIT: It should be a RemoveIf ONLY if the ID in your data souce is a unique field, otherwise it will delete everything with that ID

View solution in original post

Highlighted
Community Support
Community Support

Re: Delete a record in Azure SQL data table from PowerApp

Hi @lilyd99 ,

 

Can you share the error information?

First, I thin your formula can be simplified to  Remove('[dbo].[Input_Table]', BrowseGallery1.Selected);

Second, ensure your SQL table isn't read-only, in another word, can you write data back to SQL table? If not, please check if your SQL table contains a primary key.  if not ,please add one, you can write your CREATE statement in SQL like this:

 

CREATE TABLE dbo.TableName (
    Id INT IDENTITY(1,1) PRIMARY KEY NOT NULL,
    ...
)

 

Thrid, If two above steps are prefect, please try to delete your SQL connection, re-install On-premises Gateway ,and re-add the connection.

Please take a try and check if your issue is fixed.

Best regards,

Sik

If my post is helpful for you, please click on “Accept as Solution” to help other members find it more quickly.

 

Highlighted
Frequent Visitor

Re: Delete a record in Azure SQL data table from PowerApp

Thanks for you suggestion. I used the RemoveIf for the OnSelect:

RemoveIf('[dbo].[Input_Table]',Input_ID = BrowseGallery1.Selected.Input_ID);

 

Then I got this error: This formula has side effects and cannot be evaluated.

Input_ID is Primary Key of my table.

 

Can you share thoughts on how to fix it?

 

Thanks

 

Highlighted
Frequent Visitor

Re: Delete a record in Azure SQL data table from PowerApp

I can delete records in the database table via  MS SQL Management Studio. The table is not read-only.

Thanks

Highlighted
Community Support
Community Support

Re: Delete a record in Azure SQL data table from PowerApp

Hi @lilyd99 ,

 

I mean that if you can create record to SQL Table in PowerApps.

I guess the Issue is mainly caused by SQL connection, because your formula works fine on my side.

Could you try to delete the SQL connection, re-login the On-premise Gateway and re-add the SQL connection again?

Best regards,

Sik

If my post is helpful for you, please click on “Accept as Solution” to help other members find it more quickly.

Highlighted
Frequent Visitor

Re: Delete a record in Azure SQL data table from PowerApp

I have a trigger on the table. As a result, the deletion to that table from PowerApps didn't work.

This article mention the PowerApps Limitation.

https://docs.microsoft.com/en-us/connectors/sql/

 

Thanks for you help.

 

Highlighted
Resolver I
Resolver I

Re: Delete a record in Azure SQL data table from PowerApp

Ah yes. You will have to use a flow to execute a SQL query and pass in the parameters from PowerApps. This also goes for adding, editing and deleting also.

Helpful resources

Announcements
secondImage

Demo-Extravaganza 2020

Check out these cool Power Apps & vote on your favorite!

secondImage

Community Highlights

Check out whats happening in Power Apps

secondImage

Community User Group Member Badges

FIll out a quick form to claim your community user group member badge today!

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (7,779)