+ Start a Discussion

Insert failed. First exception on row 0; first error: INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY



I looked into the code, this error is hrown if i have the lookup field to opportunity from one of the custom object. If i comment this lookup field then i am getting the insert passed.


i checked for the access of the user, since this is portal user, i don't see opportunity in the profile for them. Anybody here to help me please.


here is the block of code

if (!(('').equalsignorecase(referralName2))){ 
                    if (!Pattern.matches('^[a-zA-Z0-9][\\w\\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\\w\\.-]*[a-zA-Z0-9]\\.[a-zA-Z][a-zA-Z\\.]*[a-zA-Z]$', referralemail2)) {
                    ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, Label.App_Val_Error_Email_Format));
                    referral__c ref3 = new referral__c();
                    ref3.Name__c = referralName2;
                    ref3.Related_Opportunity__c = this.opp.Opportunity__c;
                    ref3.Account__c = this.Opp.Account__c;
                    ref3.Email__c = referralemail2;
                    ref3.Phone__c = referralphone2;
                    insert ref3;


if i comment the below line, insert is getting passed.


ref3.Related_Opportunity__c = this.opp.Opportunity__c;

  Related opportunity is a custom lookup field on opportunity.


this.opp.Opportunity__c is having the the opportunity id, as i have the samething in the URL and i get the ID on it.






Please give the access to 'Related_Opportunity__c' field for  portal user profile.

Setup->Customize->Opprtunites->Custom lookup field.-> click on 'Set Field Level security' -> Enable the permssion for Portal User profile and save.







Related_opportunity__c field is a field in Referral object, which has lookup relationship with opportunity.


customer portal user license type is "Overage High Volume Customer Portal", so i am not seeing all the objects in their profile to give permission to them.