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
sunithasunitha 

Entity is not org-accessible at line 1 column 1

hi could u give the soluti

trigger salesContacts on Opportunity (after insert){
List<OpportunityShare> sharesToCreate = new List<OpportunityShare>();
List<OpportunityTeamMember> oppteam = new List<OpportunityTeamMember> ();

if(trigger.new[0].Partner_User__c != null) {
OpportunityShare oshare = new OpportunityShare();
oshare.OpportunityAccessLevel = 'Edit';
oshare.OpportunityId = trigger.new[0].Id;
oshare.UserOrGroupId = trigger.new[0].Partner_User__c;
sharesToCreate.add(oshare);

OpportunityTeamMember ot = new OpportunityTeamMember();
ot.OpportunityId = trigger.new[0].Id;
ot.UserId = trigger.new[0].Partner_User__c;
ot.TeamMemberRole = 'Reseller';
oppteam.add(ot);
}


// do the DML to create shares
if (!sharesToCreate.isEmpty())
insert sharesToCreate;

// do the DML to create shares
if (!oppteam.isEmpty())
insert oppteam;
}

on for above error given the code below

Best Answer chosen by Admin (Salesforce Developers) 
Vinit_KumarVinit_Kumar

The error is self explanatory you don't have any field called Partner_User__c on Opportunity object.Please go tto Setup and see the API name of the field you want to use and replace this with the correct name.

All Answers

Vinit_KumarVinit_Kumar

The error is baecause of one of the follwing reasosn.

 

1.) You don't have OpportunityTeams enabled in your org.

 

2.) Your Opportunity sharing OWD settings is neither Public Read Only nor Private

sunithasunitha

 thank you for giving the reply ,  i did that change but error came

 

 

 

Error: Compile Error: Invalid field Partner_User__c for SObject Opportunity at line 9 column 

Vinit_KumarVinit_Kumar

The error is self explanatory you don't have any field called Partner_User__c on Opportunity object.Please go tto Setup and see the API name of the field you want to use and replace this with the correct name.

This was selected as the best answer
sunithasunitha

Thank you it was successfully executed

surendra kumar 7surendra kumar 7
i got the same error plz find the solution
Error: Compile Error: Entity is not org-accessible at line 1 column 1

scenario :trigger adds the opportunity owner into the sales team automatically when opportunity is created 

trigger oppteam on opportunity(after insert)
{
    list<opportunityteammember> oppteam=new list<opportunityteammember>();
opportunityteammember ot=new opportunityteammember();
ot.opportunityid=trigger.new[0].id;
ot.userid=trigger.new[0].ownerid;
ot.teammemberrole='accountmanager';
oppteam.add(ot);
if(oppteam!=null&&oppteam.size()>0)
{
    insert oppteam;

}