cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper III
Helper III

Delete SharePoint Record from current form

Hi,

 

How would I go about write code for a button that will delete the current record displayed on a canvas form.

This form is used also for editing the records, with a submit button. All I wish to do is delete the record instead of updating it.

 

TA

 

Mark.

5 REPLIES 5
Highlighted
Super User III
Super User III

OnSelect of your button:

Remove(Datasource, LookUp(Datasource, ID = TextboxOnYourForm.Text))

Or

Remove(Datasource, LookUp(Datasource, ID = Value(TextboxOnYourForm.Text)))

------------

If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

Highlighted
Microsoft
Microsoft

Hi@MarkIreland,

Based on the issue that you mentioned, do you want to delete the displayed record in an Edit form?

Actually, I am not sure if there is a primary column in your form which decides how to locate the current record. The formula @eka24 provided presume that your form has a primary key within. Fortunately, ID is the primary key in the SharePoint list.

You can just set the OnSelect property of the “Delete” button as below.

Remove(SPlist, LookUp(SPlist, ID = xxx))

As an alternative solution, I think that you can create a DataTable/Gallery via the form. Set the OnSelect property of the “Delete” button as below.

Remove(SPlist, DataTable1.Selected)

What’s more, to differ the display form with the edit form, it is necessary to create two different forms. You can create an App directly from the SharePoint list that makes you have three screens containing BrowseScreen, DetailScreen, and EditScreen.

005.png

You can view form or edit form in different forms. Further, you can delete a record by selecting it in the gallery and delete it in DetailScreen.

006.png

Best Regards,

Qi

Highlighted
Helper III
Helper III

Hi,

 

I actually found it difficult to get the record 100% for the remove function.

 

So I moved the delete function to a gallery, and added the edit there as well. So now you search for what you want, then select delete or edit as required.

 

TA

 

Mark

Highlighted

So is the issue resolved?

------------

If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

Highlighted

Yes and no.

 

Yes in that I have met my objective in what I think is more elegant way. No in that original query I still have no answer to.

 

Maybe add option to the submitForm() function to delete? And Add as new? So it perfoms the three basic functions of add, change, delete.

 

Many thanks

 

Mark

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Community Highlights

Community Highlights

Check out the Power Platform Community Highlights

Top Solution Authors
Top Kudoed Authors
Users online (8,517)