You need to sign in to do that
Don't have an account?
Arun 2
Insert account share with Rowcause value dynamically.
Hi Team,
We are trying to do apexsharing in triggers and webservices for Account Object.We can able to set sharing ID(userId or group Id),but if we set Rowcause is apart from manual its throughing error.
We are getting this exception : CheckRowcause: execution of AfterInsert caused by: System.DmlException: Insert failed. First exception on row 0; first error: FIELD_INTEGRITY_EXCEPTION, field integrity exception: RowCause (cannot insert sharing row with this cause): [RowCause]: Trigger.CheckRowcause: line 14, column 1 .
I have gone through lot of salesforce use cases docuements for this issue. I am properly using my sharing model and also I am using the latest API version i.e 35.0.
Kindly suggest the solution for the same.
Thanks
Arun.R
We are trying to do apexsharing in triggers and webservices for Account Object.We can able to set sharing ID(userId or group Id),but if we set Rowcause is apart from manual its throughing error.
We are getting this exception : CheckRowcause: execution of AfterInsert caused by: System.DmlException: Insert failed. First exception on row 0; first error: FIELD_INTEGRITY_EXCEPTION, field integrity exception: RowCause (cannot insert sharing row with this cause): [RowCause]: Trigger.CheckRowcause: line 14, column 1 .
I have gone through lot of salesforce use cases docuements for this issue. I am properly using my sharing model and also I am using the latest API version i.e 35.0.
Kindly suggest the solution for the same.
Thanks
Arun.R
trigger CheckRowcause on Account (after insert) {
List<AccountShare> shares = new List<AccountShare>();
User u = [Select id from user where Id =:'00528000000c7WG'];
for(Account a : Trigger.new){
AccountShare aShare = new AccountShare();
aShare.AccountId = a.Id;
aShare.UserOrGroupId = u.Id;
aShare.RowCause =Schema.Accountshare.RowCause.owner;
aShare.AccountAccessLevel = 'Edit';
aShare.OpportunityAccessLevel = 'Edit';
shares.add(aShare);
}
insert shares;
}