function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
youji37youji37 

insert into CaseShare object

I try to insert record into caseshare object, get the following error.

Invalid id value for this SObject type: 500R0000001bUb5IAE: Trigger.prmSharingTrigger: line 14, column 22

 

 

my code is

   

for (Case a : Trigger.new) {
       
        if(a.RecordTypeId == '012R00000008hE5'){
           CaseShare newCaseShare = new CaseShare(
                id = a.id,
                UserOrGroupId=a.CreatedById,
                CaseAccessLevel='Read'
            );

        insert newCaseShare;

Best Answer chosen by Admin (Salesforce Developers) 
werewolfwerewolf

Oh wait.  Duh.  I spoke too soon.

 

You can't set the Id field.  Set the CaseId field instead to your case's ID.

All Answers

werewolfwerewolf
That's quite curious.  I can't see anything wrong with that code.  Perhaps you may want to contact Salesforce.com support about that.
werewolfwerewolf

Oh wait.  Duh.  I spoke too soon.

 

You can't set the Id field.  Set the CaseId field instead to your case's ID.

This was selected as the best answer