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 

Error: Compile Error: Entity is not org-accessible at line 1 column 1

Hi All,

 

I am getting the below error while saving the trigger. Please correct me 

Error: Compile Error: Entity is not org-accessible at line 1 column 1

 

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;

}

 

imutsavimutsav
You need to put your first if statement into For loop
eg.
for(Opportunity oppt: Trigger.new) {
and now your code
if(oppt.Partner_User__c !=null) { _________________

anyways this is needed since you are using two lists of OpportunityShare and OpportunityTeamMember but you are not looping to get all the Opportunities' data. In place of hardcoding Trigger.net[0] use the variable Oppt(for loop variable). Do check for any typo in the code.

Let me know if it works, or else you need to troubleshoot the code by commenting most of the code then try to save it if it works then uncomment other lines and then try to save it and repeat the process to see which line is creating the issue.

Do mark this answer as solution if it works for you and give a kudos.

Thanks
Utsav