cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
lilyd99
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
ajennings1
Resolver I
Resolver I

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
ajennings1
Resolver I
Resolver I

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

v-siky-msft
Community Support
Community Support

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.

 

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

 

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

Thanks

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.

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.

 

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
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Users online (1,801)