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
ramya1ramya1 

How can a case be visible to CreatedBy User?

Hi,

 

How can we make a case visible to the created by user?

In the sharing Settings we have it as private..How can we make it visible to only  the createdby user?

 

Thanks in Advance.

 

Ramya.

Bhawani SharmaBhawani Sharma
You can do this by manual sharing. You need to create a record in CaseShare table with CreatedById and CaseId
ramya1ramya1

HI ,

Thanks for reply.

 

I have read Caseshare, when I am trying to Insert record then I am getting Error:

Error: Invalid Data. 
Review all error messages below to correct your data.
Apex trigger prmSharingTrigger caused an unexpected exception, contact your administrator: prmSharingTrigger: execution of AfterInsert caused by: System.DmlException: Insert failed. First exception on row 0; first error: INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY, insufficient access rights on cross-reference id: []: Trigger.prmSharingTrigger: line 5, column 1

 

trigger SharingTrigger on Case (after insert) {
for (Case a : Trigger.new)
{
CaseShare newCaseShare = new CaseShare(caseId=a.id,UserOrGroupId=a.LastModifiedById,CaseAccessLevel='Read');
Insert newCaseShare;
}

Bhawani SharmaBhawani Sharma

Is this casse associated with any account?

ramya1ramya1
Ya
Bhawani SharmaBhawani Sharma
Please add one record for AccountShare in also
Team WorksTeam Works

Hi Ramya,

 

Do you have the solution to this yet?

trigger SharingTrigger on Case (after insert) {
for (Case a : Trigger.new)
{
CaseShare newCaseShare = new CaseShare(caseId=a.id,UserOrGroupId=a.LastModifiedById,CaseAccessLevel='Read');
Insert newCaseShare;
}

The above code is throwing the error :

Compile Error: Field is not writeable: AccountShare.AccountAccessLevel at line 4 column 64

Compile Error: Field is not writeable: CaseShare.CaseId at line 6 column 47

 

Please help..

Thanks!