You need to sign in to do that
Don't have an account?

I keep getting this error: "Type is not visible: Opportunity". How do I fix this?
I think it has to do with my Apex test classes - I tried to change some classes from "private" to "public" but the classes wouldn't save and just show this error instead. (I am going through Apex Academy on pluralsight, so this is the example from there - the suggested method was "private class" in line 2, but it still gives me the error when I try to save it as "public class".
@isTest
private class LeadingCompetitorTest {
@isTest static void createOppWithCompetitors() {
// Create an opportunity and set required fields
Opportunity opp = new Opportunity();
opp.Name = 'Big Deal';
opp.CloseDate = Date.today();
opp.StageName = 'Prospecting';
// Set competitor price fields
opp.Competitor_1_Price__c = 5000;
opp.Competitor_2_Price__c = 15000;
opp.Competitor_3_Price__c = 25000;
// Set competitor fields
opp.Competitor_1__c = 'Amazon';
opp.Competitor_2__c = 'Google';
opp.Competitor_3__c = 'Microsoft';
insert opp;
System.debug('Opportunity ' + opp.Name + ' inserted with all comeptitor fields populated.');
}
}
@isTest
private class LeadingCompetitorTest {
@isTest static void createOppWithCompetitors() {
// Create an opportunity and set required fields
Opportunity opp = new Opportunity();
opp.Name = 'Big Deal';
opp.CloseDate = Date.today();
opp.StageName = 'Prospecting';
// Set competitor price fields
opp.Competitor_1_Price__c = 5000;
opp.Competitor_2_Price__c = 15000;
opp.Competitor_3_Price__c = 25000;
// Set competitor fields
opp.Competitor_1__c = 'Amazon';
opp.Competitor_2__c = 'Google';
opp.Competitor_3__c = 'Microsoft';
insert opp;
System.debug('Opportunity ' + opp.Name + ' inserted with all comeptitor fields populated.');
}
}
Please check you have created any class with Opportunity name ? If yes then please rename that class and try again.