For example am the owner of the record then only i should be able to delete the record, And i should not be able to delete records created by others.I cant give ModifyAll permission to that profile as it is not Admin profile. And OWD is private ,What is the other option?

  • 1
    Hi. Please edit your question as it isn't clear just what the problem you face is. A user should be able to delete records where they are the Owner (rather that CreatedBy). Are you correctly managing the Owner here? What sort of user is it (a full platform user, a community user, a guest user)?
    – Phil W
    Feb 15, 2021 at 10:09
  • Updated the post, hope you understood my query. Delete option should be given only to the records createdBy the user "X" ,not for the other records which are not created by "X" user. If Y has created the record he should have option of deleting not "X". @PhilW
    – user91784
    Feb 15, 2021 at 12:13
  • If you use Owner you can do this via standard functionality in Salesforce. If you insist on using CreatedBy then you need to add some automation (e.g. a flow or a trigger) that verifies that the contextual user for a record deletion is the same as the CreatedBy for the record.
    – Phil W
    Feb 15, 2021 at 12:30
  • I want to do on owner how can we do that through configuration.
    – user91784
    Feb 15, 2021 at 13:01

2 Answers 2


If you use Owner, rather than CreatedBy, you can deal with this as follows:

  • Set the OWD sharing for your object type to Private or Read Only.
  • Do not set up sharing rules for this object type.
  • Ensure the user profile has the ability to Delete.
  • Ensure that the Owner is always set on record creation using the contextual user (so it matches CreatedBy).

That's it. At that point your users will only be able to view, edit and/or delete their own records (it depends on what you select for OWDs).

On the other hand if you want to use CreatedBy then you need to add automation (such as a trigger) that verifies that the contextual user's ID matches that of the CreatedBy and where it doesn't causes a failure. (I would suggest a record-triggered flow on deletion but these don't seem to be able to cause a failure or test the contextual user without dropping into Apex anyway.)

It would be as simple as doing something like the following on before delete via a trigger on your relevant record object type (I call it MyRecord__c here):

for (MyRecord__c record : Trigger.old) {
    if (UserInfo.getUserId() != record.CreatedById) {
        record.addError('You are not allowed to delete records you didn\'t create');
  • How about if i want to add permission set, in this For example if permission set is assigned then anyone can delete.
    – user91784
    Feb 26, 2021 at 17:19
  • No. If following the second option, using the CreatedById, you already need to provide the ability to delete via permissions regardless of whether this is via a profile or permission set. This loop is checking that the user deleting is the user who created. Additionally, if taking the first option, permission sets don't affect sharing and you already need to ensure the user has the permission to delete their own records.
    – Phil W
    Feb 26, 2021 at 17:28
  • Thanks for the response, but what i mean is if user X is manager but if he wants to delete the User Y record who reports to X ,then how is it possible?
    – user91784
    Feb 26, 2021 at 17:36
  • You can do that very easily using role-based Sharing Groups with the first approach.
    – Phil W
    Feb 26, 2021 at 17:41
  • Ok i will it a try , thank you so much Phil :)
    – user91784
    Feb 26, 2021 at 17:43

You can give Delete permission on the Profiles for the desired objects which they should be able to remove. That should work for you.

  • I have tried this but user can delete others created records too. my requirement is if createdby me then only i should be able to delete the record not others record.
    – user91784
    Feb 15, 2021 at 12:07

You must log in to answer this question.