Saturday, December 26, 2015

Salesforce: Change Record Owner

In general, to transfer a record from a user to you or to someone else in Salesforce, you need to have following access or permission:
  • you are the record owner and you have Edit permission on the object, or
  • record owned by a user under you in the role hierarchy (Grant Access Using Hierarchies must be enabled for that object) and you have Edit permission on the object, or
  • you have Transfer Record permission and Edit permission on the object, or 
  • you have Modify All permission for the given object, regardless of who owns the record, or
  • you have Modify All Data permission, regardless of who owns the record.
If you see above criteria's, having edit access on a record doesn't mean you will be able to transfer a record you can edit. If you click Sharing button on the record, it will show the explanation of Access Levels:
  • Full Access - User can view, edit, delete, and transfer the record. The user can also extend sharing access to other users.
  • Read/Write - User can view and edit the record, and add associated records, notes, and attachments to it.
While using sharing rules in OWD, we cannot share object access to Full Access.

Transfer Record Permission
For a user with Transfer Record permission, but no Edit permission on record (not on the object):
- will be able to change the owner from Change Owner link from record page
- will be able to change the owner from list view (for Lead and Contact)
- will be able to mass transfer record using "Mass Transfer Records" from the setup menu

With this, it is clear that transfer record owner does not relate with edit record permission, but related with edit object permission.

Summary: user with "Transfer Record" permission allowed to transfer ALL records, as long as the user has Edit permission to the object. Read again here "edit on object" NOT "edit on record", this means, the user will be able to transfer record owner even user do not have Edit access to that record.

Transfer Record permission will include Transfer Case and Transfer Lead permission.

A special case to transfer Campaign, users must also have the "Marketing User" checkbox selected on their user record.

Use Case: allow a user to change owner as long as the user has edit access to the record, edit access may be given from OWD sharing rules or manual sharing.

Solution: based on the above criteria, this use case doesn't fit any criteria. In short, we need to customize with write trigger to query to object UserRecordAccess, example: SELECT RecordId, HasEditAccess FROM UserRecordAccess WHERE UserId='00590000000OoB0AAK' and RecordId='00690000005vUbw' and "Transfer Record" permission must be given to that users.

Other Solution: this may be not an ideal solution, but if you do not have developers to write a trigger, you can use validation rules based on conditions from user object, example: users located in West area only allowed to transfer record owned by users in the same West area, sample validation rule:
TEXT($User.Area__c) <> PRIORVALUE(Owner.Area__c) || 
TEXT($User.Area__c) <> Owner.Area__c 

** this validation rule will stop user to edit record if the record owner is not in the same Area with the user, or the prior record owner is not in the same with user's Area.

Blog last modified date: 23 Oct 2016

No comments:

Post a Comment

Page-level ad