You need to sign in to do that
Don't have an account?
VT878
Apex Managed Sharing
Hi, I have a problem with Apex Managed Sharing and I read this guide: https://developer.salesforce.com/page/Using_Apex_Managed_Sharing_to_Create_Custom_Record_Sharing_Logic
So, on my custom sObject ("pse_Idea__c") I created a Apex Sharing Reason named "Apex" and its OWD is Public Read-Only:
I created an after insert trigger on this object to insert a record in pse_Idea__share to share this record with the owner of father's object:
When I insert a pse_Idea__c record I debug this error:
Can you give me a hand?
So, on my custom sObject ("pse_Idea__c") I created a Apex Sharing Reason named "Apex" and its OWD is Public Read-Only:
I created an after insert trigger on this object to insert a record in pse_Idea__share to share this record with the owner of father's object:
trigger FirstTrigger on pse_Idea__c (after insert) { List<pse_Idea__c> listSolution = new List<pse_Idea__c>(); List<pse_Idea__Share> listIdeaSharing = new List<pse_Idea__Share>(); if(Trigger.isInsert && Trigger.isAfter) { listSolution = [SELECT ID, pse_Pain_Point__r.OwnerId FROM pse_Idea__c WHERE ID IN: Trigger.newMap.KeySet() ]; System.debug('@@@ listSolution: ' + listSolution); for (pse_Idea__c item : listSolution) { listIdeaSharing.add(new pse_Idea__Share(AccessLevel='Edit', ParentID=item.ID, UserOrGroupId=item.pse_Pain_Point__r.OwnerId, RowCause=Schema.pse_Idea__Share.RowCause.Apex__c)); } try { System.debug('@@@ TRIGGER on pse_Idea__c INSERT : ' + listIdeaSharing); insert listIdeaSharing; } catch(Exception e) { System.debug('@@@ TRIGGER on pse_Idea__c Exception :'+e.getMessage()); } } }
When I insert a pse_Idea__c record I debug this error:
19:09:08.0 (255505853)|EXCEPTION_THROWN|[20]|System.DmlException: Insert failed. First exception on row 0; first error: INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY, insufficient access rights on cross-reference id: [] 19:09:08.0 (255909781)|USER_DEBUG|[23]|DEBUG|@@@ TRIGGER on pse_Idea__c Exception :Insert failed. First exception on row 0; first error: INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY, insufficient access rights on cross-reference id: []But If I insert a record in pse_Idea__share in Execute Anonymous Windows the record is inserted.
Can you give me a hand?
SalesFORCE_enFORCEr
Are you creating the Idea record as some other user which has limited access?