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?

1 Answer 1

2

Change it to:

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

Apex is case insensitive.

1
  • d'oh! totally forgot about it. thanks heaps! (it works:)
    – user39399
    Jun 17, 2015 at 11:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .