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
SwayampravaSwayamprava 

Sharing setting Trigger

Hi , I am facing problem in having access level "Full Access".

Decision is the Parent object.
RACI is the Child object.

 

On a Decision i can add Different RACI records using a custom buttom "Add New Raci". This opens a Visual force page where i can add Raci records . Each record has a lookup to user i.e. "NameOfUser".

 

There is a Check box on Decision "Raci_Can_add_or_delete_ Other_Members__c." When the Checkbox it True the users added in the RACI on the relaed list Should able to delete other existing records.

 

For Add it is working fine . I have the issue with Delete records. The users have a custom standard profile. (with no "Modify all").

 

Trigger Code:

 

if(r.Approval_Status__c=='Approved/Accepted'
&& thisd.RACI_can_add_or_delete_Other_Members__c==True && r.OwnerId!=r.NameofUser__c ){

RACI__Share RACIShare = new RACI__Share();
RACIShare.ParentId = r.Id;
for(Raci__c rnum:rnumberswithoutnameofuser)
RACIShare.UserOrGroupId = rnum.NameofUser__c;
RACIShare.AccessLevel = 'All';
Insert RACIShare;

}


In the code it is accepting the 'All' but if i made the checkbox is true then the error message is :

 

Error:Apex trigger DecisionShareAndRaciShare caused an unexpected exception, contact your administrator: DecisionShareAndRaciShare: execution of AfterUpdate caused by: System.DmlException: Insert failed. First exception on row 0; first error: INVALID_ACCESS_LEVEL, : []: Trigger.DecisionShareAndRaciShare: line 86, column 1

 

 

Because the AccessLevel for these user have : Readoly and Read/Write options. No Full Acess is there.

My question is how we can give the Full Access to the users.(we should not modify the profile).

Navatar_DbSupNavatar_DbSup

Hi,


User can’t delete any record owned by someone else until and unless that user having view all and modify all permission on profile label. So use can’t delete that record.

 

Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved. 

Starz26Starz26

You will have to create custome code to perform the delete.

 

If you are simply using a command button calling the {!delete} standard method, you will get an error.

 

However, if you do the delete through code based on the criteria you developed, you can delete the records. Call that method from the command button and all should be good.