AccountShare) so runtime logic can grant or revoke access — still subject to your design and tests.Manual sharing in the UI creates share rows. Apex managed sharing does the same thing in code — useful when rules are too static and you need to react to field changes, teams, or external ids.
User Sam’s access
No extra share
Storage
—
AccountShare sh = new AccountShare(); sh.AccountId = acct.Id; sh.UserOrGroupId = samUserId; sh.AccountAccessLevel = 'Read'; sh.RowCause = Schema.AccountShare.RowCause.Manual; // or custom Apex cause insert sh;
Real code uses correct object types, error handling, and tests. RowCause values depend on your org — read Salesforce docs for the share object you need.