cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
najruli
Level: Powered On

How to delete REMOVE row in SQL table

Is is possible to delete single row in sql table from powerapps Icon. I am using gallery to add miltiple line item.

I am able to collect and Patch to SQL . I am able to remove from collection single row Remove(CollectionName, ThisItem) but not sure how to do similar thing for SQL any help will be appriciated.

Regards,

najruli

1 ACCEPTED SOLUTION

Accepted Solutions
najruli
Level: Powered On

Re: How to delete REMOVE row in SQL table

In fact, Instead removing rows directly from SQL Table, I created collect table which was easy add and delete Line Items after finishing my adds into collect then I added another Button where I saved all the Collect table to SQL Table.
Save Collect Table to SQL Table Code :

ForAll(CollectTable,
                                              Patch( SQL_Table, Defaults(SQL_Table),
                                                   {

                                         ID: ID,
                                         Name: Name,

                                         Address: Address,

                                        Email: Email

                                                   }

                                       )

);

Note: Collect Columns must match SQL Table Columns Names.

 

Regards,

3 REPLIES 3
Super User
Super User

Re: How to delete REMOVE row in SQL table

Hi Najruli,

A simple way to remove a single row from a SQL Server table is to call the RemoveIf function and to provide a primary key value. As an example, here's how to remove a row from a customer table where CustomerID=8.

RemoveIf('[dbo].[Customer]', 
          CustomerID=8
)
Community Support Team
Community Support Team

Re: How to delete REMOVE row in SQL table

Hi @najruli ,

Could you please share a bit more about your scenario?

Do you want to remove same record from your SQL Table when you remove single row from your Collection?

Further, do you collect the new items into a Collection, and then patch the Collection into your SQL Table?

 

If you want to remove one record from your SQL Table, you must find the record in your SQL Table firstly. I have made a test on my side, please take a try with the following workaround:

Add the following formula within the "Remove" icon within your Gallery:

Remove(
        '[dbo].[YourSQLTable]',
         LookUp('[dbo].[YourSQLTable]', PrimaryColumn = ThisItem.PrimaryColumn)   /* <-- Find the reocrd you want to update */
)

Note: The PrimaryColumn represents the Primary column in your SQL Table, which could identify one record uniquely.

 

More details about the LookUp function in PowerApps, please check the following article:

LookUp function

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
najruli
Level: Powered On

Re: How to delete REMOVE row in SQL table

In fact, Instead removing rows directly from SQL Table, I created collect table which was easy add and delete Line Items after finishing my adds into collect then I added another Button where I saved all the Collect table to SQL Table.
Save Collect Table to SQL Table Code :

ForAll(CollectTable,
                                              Patch( SQL_Table, Defaults(SQL_Table),
                                                   {

                                         ID: ID,
                                         Name: Name,

                                         Address: Address,

                                        Email: Email

                                                   }

                                       )

);

Note: Collect Columns must match SQL Table Columns Names.

 

Regards,

Helpful resources

Announcements
firstImage

PowerApps Monthly Community Call!

Join us next Wednesday for our Demo Extravaganza, October 16, 2019 8am PDT.

firstImage

Microsoft Business Applications Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

SecondImage

Power Platform Summit North America

Register by September 5 to save $200

Top Kudoed Authors
Users Online
Currently online: 355 members 4,758 guests
Please welcome our newest community members: