You need to sign in to do that
Don't have an account?

Regarding accessing CaseShare record in Apex
Hi,
I am trying to delete a CaseShare record using the below code but getting an exception:
List<CaseShare> c = [Select Id, CaseId, CaseAccessLevel, UserOrGroupId, RowCause From CaseShare where CaseAccessLevel='Edit' and CaseId = '50017000001b88e'];
System.debug(c);
delete c;
System.DmlException: Delete failed. First exception on row 0 with id 01n17000003gg7wAAA; first error: INVALID_CROSS_REFERENCE_KEY, id does not exist: []
I can see the SOQL query returning a record but not able to delete it. What could be the reason for not allowing deletion/updation. I am System Administrator.
Thanks.
I am trying to delete a CaseShare record using the below code but getting an exception:
List<CaseShare> c = [Select Id, CaseId, CaseAccessLevel, UserOrGroupId, RowCause From CaseShare where CaseAccessLevel='Edit' and CaseId = '50017000001b88e'];
System.debug(c);
delete c;
System.DmlException: Delete failed. First exception on row 0 with id 01n17000003gg7wAAA; first error: INVALID_CROSS_REFERENCE_KEY, id does not exist: []
I can see the SOQL query returning a record but not able to delete it. What could be the reason for not allowing deletion/updation. I am System Administrator.
Thanks.
If you check the schema then you will come to know that you can not delete the CaseShare object..It is only querable..
P.S. If my answer helps you to solve your problem please mark it as best answer. It will help other to find best answer.
Thanks,
Sandeep
Salesforce Certified Developer
From below, CaseShare can be deleteable:
May be somesetting are not enabled in my org so I am not able to see this...Okay now I think I can help you out..
Can you paste your code here where you are getting the error ?
Thanks,
Sandeep
I don't think so that you can remove the share record where RowCause is Owner.