You need to sign in to do that
Don't have an account?
Default sharing change when apex script examines sharing
Hi,
In the help docs I see the the below at https://na7.salesforce.com/help/doc/user_ed.jsp?section=help&target=security_sharing_considerations.htm&loc=help&hash=d533368e169
You cannot change the organization-wide default settings for an object if an Apex script examines the sharing entries associated with that object. For example, if a script retrieves the users and groups who have sharing access on an account (represented as the AccountShare
object in the code), then you cannot edit the organization-wide sharing default for accounts. For more information, see Force.com Apex Code Overview.
I have an apex class that does the below, and it then linked to a VF page to display the results. From the paragraph above, it looks like having this code in my DE should prevent me from changing the default sharing for Accounts. But it does not. I can change the default and I see the entries in AccountShare get wipe out when I go to public, then I can add rules when I go back to private, etc...
Does anyone know what the above paragraph in the help docs really means? If I package my class in a managed package, any ideas on how it would impact the installing org? I am building an app to check accountshare, contactshare, leadshare, etc...
Thanks!
public class TestSharing {
public List<AccountShare> alist {get;set;}
public TestSharing() {
alist = [Select a.AccountAccessLevel, a.AccountId, a.Account.AccountNumber, a.Account.AnnualRevenue, a.Account.BillingCity, a.Account.BillingCountry, a.Account.BillingPostalCode, a.Account.BillingState, a.Account.BillingStreet, a.Account.ConnectionReceivedId, a.Account.ConnectionSentId, a.Account.CreatedById, a.Account.CreatedDate, a.Account.Description, a.Account.Fax, a.Account.Id, a.Account.Industry, a.Account.IsDeleted, a.Account.LastActivityDate, a.Account.LastModifiedById, a.Account.LastModifiedDate, a.Account.MasterRecordId, a.Account.Name, a.Account.NumberOfEmployees, a.Account.OwnerId, a.Account.Ownership, a.Account.ParentId, a.Account.Phone, a.Account.Rating, a.Account.shc__Active__c, a.Account.shc__CustomerPriority__c, a.Account.shc__NumberofLocations__c, a.Account.shc__SLA__c, a.Account.shc__SLAExpirationDate__c, a.Account.shc__SLASerialNumber__c, a.Account.shc__UpsellOpportunity__c, a.Account.ShippingCity, a.Account.ShippingCountry, a.Account.ShippingPostalCode, a.Account.ShippingState, a.Account.ShippingStreet, a.Account.Sic, a.Account.Site, a.Account.SystemModstamp, a.Account.TickerSymbol, a.Account.Type, a.Account.Website, a.CaseAccessLevel, a.ContactAccessLevel, a.Id, a.IsDeleted, a.LastModifiedById, a.LastModifiedBy.Alias, a.LastModifiedBy.CallCenterId, a.LastModifiedBy.City, a.LastModifiedBy.CommunityNickname, a.LastModifiedBy.CompanyName, a.LastModifiedBy.ContactId, a.LastModifiedBy.Country, a.LastModifiedBy.CreatedById, a.LastModifiedBy.CreatedDate, a.LastModifiedBy.DelegatedApproverId, a.LastModifiedBy.Department, a.LastModifiedBy.Division, a.LastModifiedBy.Email, a.LastModifiedBy.EmailEncodingKey, a.LastModifiedBy.EmployeeNumber, a.LastModifiedBy.Extension, a.LastModifiedBy.Fax, a.LastModifiedBy.FirstName, a.LastModifiedBy.ForecastEnabled, a.LastModifiedBy.Id, a.LastModifiedBy.IsActive, a.LastModifiedBy.LanguageLocaleKey, a.LastModifiedBy.LastLoginDate, a.LastModifiedBy.LastModifiedById, a.LastModifiedBy.LastModifiedDate, a.LastModifiedBy.LastName, a.LastModifiedBy.LocaleSidKey, a.LastModifiedBy.ManagerId, a.LastModifiedBy.MobilePhone, a.LastModifiedBy.Name, a.LastModifiedBy.OfflinePdaTrialExpirationDate, a.LastModifiedBy.OfflineTrialExpirationDate, a.LastModifiedBy.Phone, a.LastModifiedBy.PostalCode, a.LastModifiedBy.ProfileId, a.LastModifiedBy.ReceivesAdminInfoEmails, a.LastModifiedBy.ReceivesInfoEmails, a.LastModifiedBy.State, a.LastModifiedBy.Street, a.LastModifiedBy.SystemModstamp, a.LastModifiedBy.TimeZoneSidKey, a.LastModifiedBy.Title, a.LastModifiedBy.Username, a.LastModifiedBy.UserPermissionsCallCenterAutoLogin, a.LastModifiedBy.UserPermissionsMarketingUser, a.LastModifiedBy.UserPermissionsMobileUser, a.LastModifiedBy.UserPermissionsOfflineUser, a.LastModifiedBy.UserPreferencesActivityRemindersPopup, a.LastModifiedBy.UserPreferencesApexPagesDeveloperMode, a.LastModifiedBy.UserPreferencesEventRemindersCheckboxDefault, a.LastModifiedBy.UserPreferencesReminderSoundOff, a.LastModifiedBy.UserPreferencesTaskRemindersCheckboxDefault, a.LastModifiedBy.UserRoleId, a.LastModifiedBy.UserType, a.LastModifiedDate, a.OpportunityAccessLevel, a.RowCause, a.UserOrGroupId from AccountShare a ];
}
}