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
nbeekmannbeekman 

Unexpected "=" on populating a list

Hello,

 

I am getting an error on line 3 - Unexpected "=".  Here is what is wierd that it gives this erron in Eclipse and the Development Console but executes fine when done in Execute Anonymous.  But last week before summer 13 release it worked fine.

 

The CreateBaseForTesting() is a class that creates a temporary Oppportunity, Account, Contacts, etc.

 

Doesn't make sense... 

 

Any suggestions.

 

    Static list<Opportunity> opp;
    Create_Objects_Helper.CreateBaseForTesting();
	opp = [select Name, Id, SW_Pay_MD__c from Opportunity where Name = 'Envysion Test for Deployment' limit 1];
	if(opp.isEmpty())
		throw new MyException('>>>>>> No Opportunities found. <<<<<<');
    
	//get the factors in the static object
	Opportunity temp_opp = opp.get(0);
	temp_opp.Sales_Path__c = 'Operations input required';
	temp_opp.Inst_Discount__c = 0.30;
		
	System.debug('Updating Opportunities :' + temp_opp);
	update temp_opp;

 

Avidev9Avidev9
What I understand that this is being done from testMethod right ?
Just remove the "static" keyword from the "Static list<Opportunity> opp;". It doesnt make sense inside an function/method
nbeekmannbeekman

Avi,

 

Either way it gives the error.

Avidev9Avidev9

So your code should be looking like this (Can you highlight the line number or post the actual code)

    Create_Objects_Helper.CreateBaseForTesting();
	List<Opportunity> opp = [select Name, Id, SW_Pay_MD__c from Opportunity where Name = 'Envysion Test for Deployment' limit 1];
	if(opp.isEmpty())
		throw new MyException('>>>>>> No Opportunities found. <<<<<<');
    
	//get the factors in the static object
	Opportunity temp_opp = opp.get(0);
	temp_opp.Sales_Path__c = 'Operations input required';
	temp_opp.Inst_Discount__c = 0.30;
		
	System.debug('Updating Opportunities :' + temp_opp);
	update temp_opp;

 

Avidev9Avidev9

So your code should be looking like this (Can you highlight the line number or post the actual code)

    Create_Objects_Helper.CreateBaseForTesting();
	List<Opportunity> opp = [select Name, Id, SW_Pay_MD__c from Opportunity where Name = 'Envysion Test for Deployment' limit 1];
	if(opp.isEmpty())
		throw new MyException('>>>>>> No Opportunities found. <<<<<<');
    
	//get the factors in the static object
	Opportunity temp_opp = opp.get(0);
	temp_opp.Sales_Path__c = 'Operations input required';
	temp_opp.Inst_Discount__c = 0.30;
		
	System.debug('Updating Opportunities :' + temp_opp);
	update temp_opp;