0

Is it possible to prevent a user who has read-only acces to an object OWD Private creating child records with another owner of the parent record. I currently have a custom object where I can add child records. Both the parent and the child have read-only sharing rules. The user has no extra permissions for these objects nor read all data or view all checked. The user is not able to edit, delete childrecords but is still able to create childrecords. Am I missing something or do I need to create a trigger to prevent creation of new childrecords based on sharing of parent object?

The user should be able to create parent records and add childrecords. When the user is the owner. When the user is not the owner and sharing is read-only this should not be possible.

Thanks in advance.

1 Answer 1

1

Sharing rules work along with CRUD. If you have 2 objects Parent and Child. OWD for both is Private.

User A is the owner of Record 1 in Parent object, then

  • User A can create child record if they have Create permission on Child
  • User B (not the owner) can create child record if they have Create permission + Read access on Parent record 1.

If you simply want to prevent any user who is not the owner of parent record to create child records, you can create a validation

$User.Id <> Parent__r.OwnerId

If you want to check other conditions like the user who has View All/ View All data permission should be able to create child records for any parent records, then you can either

  1. Write a trigger OR
  2. Assign these users a custom permission and extend the above validation.

The other option would be to convert the relation to Master Detail but that would be a lot of effort if these objects are already existing.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .