function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
GobbledigookGobbledigook 

Delete on Related List

Hey all, pretty straightforward question:

 

If I have some code that will override the Standard Delete button on a custom object through Visualforce, would Deleting the same custom object through a related list fire off that code? 

skodisanaskodisana

Hi,

 

Try the below code:

 

{!REQUIRESCRIPT("/soap/ajax/13.0/connection.js")} 

var records = {!GETRECORDIDS($ObjectType.Case)};
var newRecords = [];

if (records[0] == null)
{
alert("Please select at least one row")
}
else
{
for (var n=0; n<records.length; n++) {
var c = new sforce.SObject("Case");
c.id = records[n];
c.Status = "New";
newRecords.push(c);
}

delete newRecords;

window.location.reload();
}
jwetzlerjwetzler

Yes, did you try it? If you override the delete action (via the Buttons and Links section in the setup tree) with a Visualforce page, that page will be requested whenever you try to delete something via the UI, whether it's via the action links on the list view or related lists, or the delete button on a record view.