Skip to main content

Code reviews rule: Update roleAndSubordinates to roleAndSubordinatesInternal

Written by David Martin
Updated this week

Update roleAndSubordinates to roleAndSubordinatesInternal

Why is this an issue?

The default sharing group name has changed from "Roles and Subordinates" (roleAndSubordinates) to "Roles and Internal Subordinates" (roleAndSubordinatesInternal). Using the old name may cause sharing rules to fail, incorrect permission assignments or runtime errors when sharing records.

Examples

Example of incorrect code:

// Old sharing group name - deprecated
List<Account> accounts = [
SELECT Id, Name
FROM Account
WHERE OwnerId IN (SELECT Id FROM User WHERE Id = :managerUserId.roleAndSubordinates)
];

Example of correct code:

// New sharing group name
List<Account> accounts = [
SELECT Id, Name
FROM Account
WHERE OwnerId IN (SELECT Id FROM User WHERE Id = :managerUserId.roleAndSubordinatesInternal)
];

How can I fix violations?

This rule supports autofix. Additionally, you should:

  1. Update references: Replace roleAndSubordinates with roleAndSubordinatesInternal.

  2. Search codebase: Find all occurrences in Apex, SOQL, and metadata.

  3. Update sharing rules: Review and update any sharing rule configurations.

Resources

Did this answer your question?