2

I've got a method that redirects to another page. It does work this way:

public PageReference redirectToSetup() {
  return Page.SetupPage;
}

and this way:

public PageReference redirectToSetup() {
  PageReference page = new PageReference('/apex/SetupPage');
  page.setRedirect(true);
  return page;
}

but not his way:

public PageReference redirectToSetup() {
  PageReference page = Page.SetupPage;
  page.setRedirect(true);
  return page;
}

I'me getting the following error when trying to save it:

Error: Compile Error: Variable does not exist: Page.SetupPage

What am I doing wrong? Documentation here is using the same pattern, isn't it?

2

Change it to:

public PageReference redirectToSetup() {
  PageReference pageRef = Page.SetupPage;
  pageRef.setRedirect(true);
  return pageRef;
}

Apex is case insensitive.

| improve this answer | |
  • d'oh! totally forgot about it. thanks heaps! (it works:) – bananka Jun 17 '15 at 11:20

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.