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
notsosmartnotsosmart 

Test Method Error: Compile Error: Variable is not visible:

My Test Method returned the error  ' Error: Compile Error: Variable is not visible: opportunityLineItemList at line 62 column 38'  This is a reference to a wrapper class that's handled in my controller extension.  This code is fully functional.  The other (non-wrapper)  fields are available. so I think my build of the extension reference is good.

Any ideas.  Thanks.

 

The code excerps are:

 

Test Method:

 

Note - line 62 is the for loop 

 

PageReference addOpportunity;

// Error: Compile Error: Variable is not visible: opportunityLineItemList at line 62 column 38
for(OpportunityLineItem item : controller.opportunityLineItemList) {
item.Opportunity__c = [SELECT id FROM Opportunity WHERE Opportunity = 'Great Opportunity'];
}

-------------------

The wrapper class:

 

/**
* Purpose : This class is a supporting Data Transfer Objects for the Trip Report custom UI.
*/
public class OpportunityLineItem {

public Integer lineNumber{ get; set; }
public Boolean isDeleted{ get; set; }
public tripOpportunityAssociation__c opportunity { get; set;}

public opportunityLineItem(){
opportunity = new tripOpportunityAssociation__c();
lineNumber = 0;
isDeleted = false;
}

public OpportunityLineItem(Integer pLineNumber, tripOpportunityAssociation__c pOpportunityItem){
opportunity = pOpportunityItem;
lineNumber = pLineNumber;
isDeleted = false;
}
}

---------------------

 

In the Controller extension:

 

public List<OpportunityLineItem> getOpportunityItemListNotDeleted(){
//List for display on the view.
List<OpportunityLineItem> listToDisplay = new List<OpportunityLineItem>();
for (OpportunityLineItem item : opportunityLineItemList){
if (item.isDeleted != true){
listToDisplay.add(item);
}
}

return listToDisplay;
}

 

 

 

JitendraJitendra

Hi,

 

In your controller class make variable "opportunityLineItemList" as public while declaring. it will solve your problem.