You need to sign in to do that
Don't have an account?
Pranil Sarode
Field is not writeable: OpportunityShare.UserOrGroupId
trigger opptyShareTrig on Opportunity (after insert) {
List<OpportunityShare> share=new List<OpportunityShare>();
User u=[select id from User where alias='knair'];
for(Opportunity op:Trigger.New){
if(op.stageName=='Closed Won'){
OpportunityShare os=new OpportunityShare();
os.OpportunityId=op.id;
os.UserOrGroupId=u.id;
os.OpportunityAccessLevel='Edit';
os.RowCause='Manual';
share.add(os);
}
}
insert share;
}
Getting Error
List<OpportunityShare> share=new List<OpportunityShare>();
User u=[select id from User where alias='knair'];
for(Opportunity op:Trigger.New){
if(op.stageName=='Closed Won'){
OpportunityShare os=new OpportunityShare();
os.OpportunityId=op.id;
os.UserOrGroupId=u.id;
os.OpportunityAccessLevel='Edit';
os.RowCause='Manual';
share.add(os);
}
}
insert share;
}
Getting Error
Greetings to you!
- Please use the code {Solved} : -
- Use the below link for further reference : -
https://salesforce.stackexchange.com/questions/15227/why-i-am-getting-field-is-not-writable-opportunityshare-userorgroupid-compile
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks and Regards,
Deepali Kulshrestha
www.kdeepali.com