You need to sign in to do that
Don't have an account?
TScott
AccountShare referenced in Apex Code, so we cannot edit ANY org-wide sharing defaults!
We have an Apex class that updates the Account sharing rules. Since we implemented this class, we cannot update any org-wide sharing defaults via the native UI. We receive this error that appears below "Default Account, Contact, and Asset Access":
Error: Unable to change sharing model because sharing objects are referenced in the following Apex code. Apex Class: UpdateAccountTeam
I don't understand why it would restrict changing any and all org-wide defaults (a bug??). Does anyone have insight into this business rule or any crafty workarounds?
Thanks. -Tom
Error: Unable to change sharing model because sharing objects are referenced in the following Apex code. Apex Class: UpdateAccountTeam
I don't understand why it would restrict changing any and all org-wide defaults (a bug??). Does anyone have insight into this business rule or any crafty workarounds?
Thanks. -Tom
A bit of an old thread, but there is answer to this (I ran into the same problem).
The share objects can be volatile, in other words, changing the sharing model may make them disappear.
Salesforce will prevent you from changing the sharing model in these circumstances, your code might break as a result of a change to the sharing model.
The solution is to avoid making any direct references to these objects, for example, if you are creating a list from a query on a sharing object, make sure that the type in the list is of type SObject, instead of the sharing type, build your query dynamically and pass the object name as a String.
Make sure to wrap it in a try catch block to avoid issues if the object disppears, you must handle that possibility in your code
Message Edited by J_C on 10-16-2009 09:27 AM
All Answers
This restriction was put into place to prevent apex code from trying to write account shares with an invalid access level. For instance, if your org-wide default is Read Only, then writing an account share using the access level "Read Only" would fail.
As a workaround, if you need to raise your org-wide default on accounts, you can create an account sharing rule using the public group "Entire Organization". This is a system maintained group that contains all of the users in your organization.
Thanks,
Andrew
NOTE: Our Account access level is currently set to Public Read Only.
Thanks. -Tom
A bit of an old thread, but there is answer to this (I ran into the same problem).
The share objects can be volatile, in other words, changing the sharing model may make them disappear.
Salesforce will prevent you from changing the sharing model in these circumstances, your code might break as a result of a change to the sharing model.
The solution is to avoid making any direct references to these objects, for example, if you are creating a list from a query on a sharing object, make sure that the type in the list is of type SObject, instead of the sharing type, build your query dynamically and pass the object name as a String.
Make sure to wrap it in a try catch block to avoid issues if the object disppears, you must handle that possibility in your code
Message Edited by J_C on 10-16-2009 09:27 AM