You need to sign in to do that
Don't have an account?
adi salesforce
trigger to share record on case
trigger casetotal on Case (after insert) {
list<caseshare>share=new list<caseshare>();
user u=[select id,name from user where name =:'karthik'];
for(case c:trigger.new){
if(c.priority=='high'&&c.origin=='email'){
caseshare cs=new caseshare();
cs.caseid=c.id;
cs.UserOrGroupId=u.id;
cs.RowCause='manual';
cs.CaseAccessLevel='all';
share.add(cs);
}
}
insert share;
}
could you correct this code because I am getting the following errors
field is not writable caseid;
field is not writable userorgroupid;
field is not writable caseaccesslevel;
field is not writable rowcause;
list<caseshare>share=new list<caseshare>();
user u=[select id,name from user where name =:'karthik'];
for(case c:trigger.new){
if(c.priority=='high'&&c.origin=='email'){
caseshare cs=new caseshare();
cs.caseid=c.id;
cs.UserOrGroupId=u.id;
cs.RowCause='manual';
cs.CaseAccessLevel='all';
share.add(cs);
}
}
insert share;
}
could you correct this code because I am getting the following errors
field is not writable caseid;
field is not writable userorgroupid;
field is not writable caseaccesslevel;
field is not writable rowcause;
The reason is your Sharing Settings of Case is 【Public Read/Write/Transfer】.
so there is no caseshare object at all, it is not exist.
You need set 【Sharing Settings】as below.
【Security Controls】⇒【Sharing Settings】⇒【Edit】
set 【Default Internal Access of 】of case object as below.
【Private】or【Public Read Only】
If you do as what i told you,caseshare object will be created automatically,
of caurse you need to wait for some minutes.
Please mark as best answer if the above helps,thank you.