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
gstocktongstockton 

Top-level type must have public or global visibility

I have been trying to implement the Multi-Wave Campaigns enhancement as outlined on John Kucera's blog recently.

 

I have developed the workflow rules and Apex triggers on my sandbox account. To deploy this to production, I need to use Eclipse, which I am new to as I am not a developer. When I go to Deploy to Production I get the following error:

 

Top-level type must have public or global visibility

 

I am unsure what this error means, or how I would correct it. 

 

The affected class file is as follows, this code apparently there merely to allow the a test class that John had provided me so that the aforementioned Apex will pass testing "

 

 

For both you have to have 75% code coverage, which means you have to create Apex tests to ensure the code works as expected.  Here’s a non-functional, but passing Apex Test Class that covers the examples on the blog.  Save this as a class and include in your package & you should pass 75%:

 

 

 

I would certainly appreciate any help, it's been quite challenging trying to do this enhancement as a novice and not knowing what the requirements are from a deployment standpoint.

 

 

private class Summer09AutomatedCampaignsTests{ static testMethod void verifyCloneTrigger(){ // Perform our data preparation. List<Lead> leads = new List<lead>{}; for(Integer i = 0; i < 10; i++){ Lead l = new Lead(LastName = 'Test Lead ' + i,Company='Company '+i); leads.add(l); } Campaign c= new Campaign(Name='Web-BBE Trial'); insert c; Campaign c2= new Campaign(Name='Web-BBE Trial Nurturing'); insert c2; campaign c3= [SELECT Id FROM Campaign WHERE Id= '70130000000AZVJ']; List<CampaignMember> campaignmembers = new List<CampaignMember>{}; // Start the test, this changes governor limit context to // that of trigger rather than test. // Insert the Account records that cause the trigger to execute. insert leads; for(Integer i = 0; i < 10; i++){ Id LeadIdi=leads[i].id; CampaignMember cm = new CampaignMember(CampaignID = c3.Id,LeadId = LeadIdi,Status='Sent'); campaignmembers.add(cm); } insert campaignmembers; test.startTest(); for(Integer i = 0; i < 10; i++){ campaignmembers[i].status='Sent'; } update campaignmembers; for(Integer i = 0; i < 10; i++){ campaignmembers[i].status='No Response-2nd Email'; } update campaignmembers; for(Integer i = 0; i < 10; i++){ campaignmembers[i].status='RSVP-Yes'; } update campaignmembers; // Stop the test, this changes limit context back to test from trigger. test.stopTest(); // Query the database for the newly inserted records. List<Lead> insertedLeads = [SELECT LastName, Company,LeadSource FROM Lead WHERE Id IN :leads]; // Assert that the Description fields contains the proper value now. /* for(l :insertedLeads){ System.assertEquals( null, l.LeadSource); } */ } public static testMethod void testUpdateCampaignMemberController() { //Use the PageReference Apex class to instantiate a page PageReference pageRef = Page.Web2CampaignMember; //In this case, the Visualforce page named 'success' is the starting point of this test method. Test.setCurrentPage(pageRef); CampaignMember cm=new CampaignMember(); ApexPages.StandardController sc = new ApexPages.StandardController(cm); UpdateCampaignMemberClass scExt = new UpdateCampaignMemberClass(sc); scExt.UpdateCM(); /* //Instantiate and construct the controller class. ApexPages.StandardController controller=new ApexPages.StandardController; //Example of calling an Action method. Same as calling any other Apex method. //Normally this is executed by a user clicking a button or a link from the Visualforce //page, but in the test method, just test the action method the same as any //other method by calling it directly. //The .getURL will return the page url the Save() method returns. String nextPage = controller.UpdateCM().getUrl(); //Check that the save() method returns the proper URL. System.assertEquals('/apex/failure?error=noParam', nextPage); //Add parameters to page URL ApexPages.currentPage().getParameters().put('qp', 'yyyy'); //Example of calling the 'setter' method for several properties. //Normally these setter methods are initiated by a user interacting with the Visualforce page, //but in a test method, just call the setter method directly. // controller.setStatus('Status'); //Verify that the success page displays */ } /* static testMethod void UpdateCampaignMemberTest() { CampaignMember CM=[select id,Status from CampaignMember where Id='00v3000000KtOfj']; CM.status='No Response-2nd Email'; update CM; Campaign c = [select Id, name from Campaign where Id = :cm.CampaignId limit 1]; If (cm.Status == 'RSVP-Yes') { c.Last_RSVP_Yes_Time__c = datetime.now(); } update(c); CampaignMember updatedCM =[select id,Status from CampaignMember where Id= :CM.Id]; System.assertEquals(True, True); System.assertEquals(c.Last_RSVP_Yes_Time__c, null); } static testMethod void InsertCampaignMemberTest() { CampaignMember CM=[select id,Status from CampaignMember where Id='70100000000DPP6']; CM.status='Sent'; CM.campaignID='70100000000DPRl'; Insert CM; CampaignMember insertedCM =[select id,Status from CampaignMember where Id= :CM.Id]; System.assertEquals('Sent', insertedCM.status); // nurtureCM.CampaignID = '70100000000DPRl'; } */ }

 

 

 

gstocktongstockton

Changing the private class to public or global causes the following error which references line 78

 

 Error: Compile Error: Invalid type: UpdateCampaignMemberClass at line 78 column 47

 

         UpdateCampaignMemberClass scExt = new UpdateCampaignMemberClass(sc);

 

I'm afraid I don't know what this one means either.