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
AnnieGAnnieG 

About deletion of objects

Hi,
         Just wonder if a deletion of object, like leads and contacts, can be intecepted so that custom logics can be added to the deletion.
         BTW, we can assign users to different profiles to limit their permissions, right?
         Thanks for your input.

Ron HessRon Hess
Yes you can limit the user ability to delete records by removing that in the user profile.

you can create a new button called Delete , and remove the existing Delete button, now you can have code to capture the delete  and perform your required actions.

with Apex Code (preview currently) you can also trigger and run code on delete actions from the browser AND the API .
AnnieGAnnieG
Thank you so much for shedding lights on it. And that is really smart.
AnnieGAnnieG
Can you do the same to the Save button? I mean the Save button in the edit page for the objects.
I tried, but seems to me there is no go for the Save button. Am I right?
Seems that only applies to the standard buttons, which doesn't include "Save".  So what can I do if
I want some extra logic embeded in the "Save" action? Like when the "Save" button on salesforce is pressed, I also want the record to be created or updated on our company's side.

Thanks for your input.
Ron HessRon Hess
No, you cannot modify the action of the save button. 

With our upcoming feature, Apex Code you will be able to build triggers that operate on data that is or has been saved, but this is not available yet.

The hard way, you can create an entire edit page in an scontrol using yards of javascript, then you can have your own save button and perform actions.  This turns out to be lots of coding, so i can't recomend it.

better to build workflow notification if you are trying to catch bad data that has been entered, or outbound messaging if you are trying to send info to another system.

what extra logic are you planning?  
AnnieGAnnieG
The extra logic here is as simple as making sure the created or updated records also exist on our system. Just some data replication stuffs.
benjasikbenjasik
Can you use outbound messaging to trigger a message to your system to replicate the data when it changes in salesforce?