3

I refreshed my sandbox from the production org and have received numerous errors on classes that were working prior to refreshing. I'm receiving following error,

unexpected token: 'public class AddNewSbirController'.

I can get around that error by creating the class by name in the developer console but then I receive error as below,

unexpected token: '='.

Nothing in this class was changed from the original sandbox to the refreshed sandbox.

public class AddNewSbirController {
SBIR_Technical_Assistance__c SBIRTAP = new SBIR_Technical_Assistance__c();
public list< SBIR_Technical_Assistance__c > listSbirtap{ get; set; }

public AddNewSbirController()
{
listSbirtap=new list<SBIR_Technical_Assistance__c>();
listSbirtap.add(SBIRTAP);
}

Public void addSbirtap()
{
SBIR_Technical_Assistance__c st = new SBIR_Technical_Assistance__c();
listSbirtap.add(st);
}
public PageReference saveSbirtap() {
for(Integer i=0; i<listSbirtap.size(); i++)
{
insert listSbirtap;
}
return Page.Allaccountssaved;
}
}

Public void addSbirtap()
{
SBIR_Technical_Assistance__c st = new SBIR_Technical_Assistance__c();
listSbirtap.add(st);
}
public PageReference saveSbirtap() {
for(Integer i=0; i<listSbirtap.size(); i++)
{
insert listSbirtap;
}
return Page.Allaccountssaved;
}
}
  • Where are you seeing the error, while running the page? – CyberJus Apr 7 '15 at 23:03
  • 1
    You verified the object SBIR_Technical_Assistance__c still exists in the sandbox after refresh? – Brian Mansfield Apr 8 '15 at 0:07
  • 1
    when you say errors, do you mean errors with running the page itself as per CyberJus, or errors when you run test coverage? If the latter, it's possible that your test classes are relying on data that is specific to 1 environment, rather than setting up the data for the test from scratch... – Stephen B Apr 8 '15 at 7:29
  • I get the error after pasting the class into the developer console and attempting to save. I can't even get to the point where I can run the class from a page or run a test. I did verify that SBIR_Technical_Assistance__c still exists. Thanks for your help. – Paul Wagner Apr 8 '15 at 13:21
  • The error is at compile. – Paul Wagner Apr 8 '15 at 16:43
1

In line 2, try taking the instantiation out and just leave the declaration, ie.

public SBIR_Technical_Assistance__c SBIRTAP;

Then put your instantiation in the constructor, ie. line 7:

SBIRTAP = new SBIR_Technical_Assistance__c();

put this before the rest of the constructor.

This should work. Not sure why it worked in a previous environment but not this one, that would still be outstanding...

0

I've seen mystery errors like this before.

The way that I've debugged this is basically to comment out all of your code and then reinsert one method at a time. Just keep going until you encounter the error again and then you can isolate where the bug is.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.