Questions tagged [pagereference]

A PageReference is a reference to an instantiation of a page. Among other attributes, PageReferences consist of a URL and a set of query parameter names and values.

Filter by
Sorted by
Tagged with
16
votes
1answer
7k views

pagereference return null vs void

I feel like I've noticed differences in the past between a pageReference returning null vs a void method. However, I can't recall now, does the pageReference returning null refresh the view state? Are ...
13
votes
2answers
2k views

Fields missing using getContent call for Visualforce rendered as PDF

I am attempting to get the content of a visualforce page that is rendered as a PDF. I make some changes to the object that the visualforce page is displaying data from, update that object, make the ...
10
votes
2answers
10k views

Best Practices : Page Reference method return null

I read about Page Reference, and the documentation states the usage of Page Reference: To view or set query string parameters and values for a page To navigate the user to a different page as the ...
10
votes
2answers
3k views

What is the difference between System.currentPageReference() and ApexPages.currentPage()?

I couldn't find this properly defined anywhere in docs on when to use System class and when to use ApexPages class to fetch current page reference. Does anyone know if there is actually any difference ...
10
votes
1answer
908 views

Visualforce Component PageReference Method: Platform Cache PUT() Not Allowed?

Right now I have a "Refresh" button on my page that collects some data and sends it to this method: public static Boolean cacheData(String index, MyObject data) { try {reportPartition.put(hash(...
10
votes
3answers
1k views

Populating Selected Records in Standard List Controllers

If you have a page using a standard list controller, like this: <apex:page standardController="Account" recordSetVar="Accounts"> You can create a custom button for account lists allowing the ...
9
votes
3answers
6k views

PageReference from embedded Visualforce page becomes inlined

I have a Visualforce page that gets embedded into the opportunity page layout. Part of the embedded page is a command button with an action defined in the controller to redirect the user to another ...
8
votes
3answers
467 views

Urban Legend? Must Return PageReference To Rerender

So when I was learning the platform, I was told during multiple code review sessions that in order to rerender after taking an action, you had to return a PageReference (even if null) in order to let ...
7
votes
3answers
10k views

How to test page messages in unit test?

I have an Apex controller which unsubscirbes users from email via an opt-out form. I have written a test class which tests the method (or atleast partially at the moment). I would like to know how I ...
7
votes
3answers
56k views

Using PageReference to redirect after new record insert

Continuing from my previous post. I want to redirect the user to a custom vf detail page when they create a new Service Order from my custom page order page (force_NewOrder). I have created a ...
7
votes
2answers
472 views

Bell icon in communities: syntax of the setTargetPageRef string?

The Winter '21 CustomNotification Class offers two ways to set the target navigated to when the message displayed under the "bell" icon is clicked: setTargetId(Id targetId) - Sets the ...
6
votes
2answers
926 views

LWC Navigation (NavigationMixin) Bug. CurrentPageReference Becomes undefined and won't navigate?

I'm running into a bizarre bug that I can't track down. When using NavigationMixin.Navigate it works just fine MOST of the time. But occasionally, it just stops navigating. Digging into it as much ...
6
votes
1answer
206 views

PageReference assertion error?reasons?

Controller: public PageReference redirectScheduleApex(){ PageReference yourPage = new PageReference('/ui/setup/apex/batch/ScheduleBatchApexPage?ac=scheduledDeltaBatchable&retURL=/apex/mailtent')...
6
votes
1answer
1k views

Returning a location hash in a page reference

I want to return a URL with a location hash in a page reference, but it appears that the system strips it out. Anybody know of a way to make this work without resorting to javascript? I can think of ...
6
votes
2answers
2k views

ActionFunction rerender messing with Pagereference

I have a javascript method on my vf page which is called by a save button. This method performs some calculations, collects some data, and sends them to the save method in my controller as parameters ...
6
votes
1answer
4k views

Redirect to standard view from VF page with nooverride parameter in SF1

The view of my custom object is overwritten by a Visualforce page for my desktop users. This VF page should not be visible for my mobile users. Before I render my VF page, I check the device to ...
6
votes
0answers
307 views

How to get a PageReference from Site.login(username, password, url) in an Apex Test

When I run this code from within a LWC controller: ApexPages.PageReference pageRef = Site.login(username, password, url); It returns a valid PageReference instance. But when I test the code in a ...
5
votes
4answers
4k views

Provide standard clone button functionality to a button on vf page

I have an object whose standard new, edit and view button are overridden with a vf page.I want a Clone button on this vf page which should work exactly like standard clone button. If suppose i open an ...
5
votes
2answers
5k views

lightning:isUrlAddressable pageReference returns null

I'm trying to use the new lightning:isUrlAddressable interface to pass a few variables into a lightning component that is inside a lightning tab. In the init function I try to get the pageRefernce ...
5
votes
1answer
1k views

CommandButton reRender causing action to fire twice

I havea custom save button on a visualforce page as below. I wanted to use actionstatus to show the user that the save process was taking place/in progress. However recently the redirect stopped for ...
5
votes
1answer
590 views

Can I get a compile-time reference to a StaticResource in Apex?

In Visualforce Pages, I love how we can do {!$Page.MyPage} or {!$Resource.MyFileZip} and get a hard binding to either, complete with namespace resolution and URL generation. In Apex we can do ...
5
votes
1answer
1k views

Spring19 release:Uncaught (in promise) TypeError

keep getting the following js error in my lightning component after the Salesforce Spring19 release: Can any one help please contextService.js:2 Uncaught (in promise) TypeError: Cannot read property '...
5
votes
1answer
1k views

oAuth from VF Page in New Lightning - Cannot redirect vf page (iFrame) to login.salesforce.com

We have a visual force page that uses the Apex PageReference method to redirect the VF page to the https://login.salesforce.com for oAuth authentication. All is working well except in the new ...
4
votes
3answers
52k views

VF controller redirect to another page

I have a Apex Controller for a VF page. I want to redirect my page to another one, only if I cannot get a specific parameter from the URL. current page: /apex/demo?param=123 -> stay on this page. ...
4
votes
3answers
292 views

How to assert on pagereference where the endpoint of pagereference is predefined [duplicate]

I have a pagereference for which I want to write a test class but get the error Expected: System.PageReference[/CustomLoginPage], Actual: System.PageReference[/CustomLoginPage]. What am I doing wrong:...
4
votes
1answer
5k views

Visualforce: Dynamically ReRender a row within <apex:repeat> by passing $Component through controller

I have a typical form with <apex:repeat> for some fields. The <apex:inputText> elements have an onChange attribute that references a script that then calls an <apex:actionFunction>, ...
4
votes
1answer
2k views

How to call a PageReference from a Constructor

I have this following apex: public class SampleController { public SampleController(){ //I want to call the the samplepage() here. } public PageReference samplepage(){ ...
4
votes
2answers
236 views

PageReference Parameters Overwritten Even With Different Case?

I ran into this issue and believe this is a Salesforce bug, and I am looking for confirmation. Maps are supposed to be key case sensitive but when we use the pageReference.getParameters.put() it does ...
4
votes
2answers
2k views

Making rest request with Oauth

I have all four Oauth token consumerKey, consumerSecret, accessKey and accessSecret. I need to make a request to a url from my apex code. Is there any library or a way to make this request. In java I ...
4
votes
1answer
2k views

What is the difference between Test.setCurrentPage vs Test.setCurrentPageReference?

I noticed that there are two methods in the Test class, looks like for the same purpose: public static Void setCurrentPage(PageReference page) public static Void setCurrentPageReference(PageReference ...
4
votes
3answers
4k views

Pagereference not working in Lightning

I have a Detail page button (VF page) and controller for it. I used Pagereferenc method to take user to the record details page: However, it works fine in the Classic, but not in Lightning. ...
3
votes
2answers
20k views

Putting parameters into PageReference

On a custom VF page (call it page1), I am using apex:commandLink to link to another custom VF page (call it page2) and perform a DML statement. I need to put a series of parameters into the URL as ...
3
votes
1answer
462 views

Ignore Duplicate Results Alerts for Visualforce Page

I have a [visualforce] page with a [standard controller] and a an [extension] that [queries] a child and grandchild of the standard controller. The grandchild records have a [duplicate] match rule. ...
3
votes
2answers
5k views

How to pass {!Case.ID} to PageReference

I am having issues understanding how to pass the {!Case.Id} value to a PageReference in a visualforce class. My VF Page is: <apex:page standardController="Case" extensions="...
3
votes
1answer
337 views

page navigation

i have a visualforce page where most of front end code is in HTML / CSS / JS. We are calling controller methods using javascript remoting. Is there any option other than window.open('new_page','...
3
votes
1answer
2k views

The page you submitted was invalid for your session

EDIT: I have overridden the New button in Case object and opening a Visualforce page but if I open the page using preview VFP I'm not getting the error and its happening only when I click on NEW ...
3
votes
1answer
4k views

The CORRECT way to redirect to a ListView from StandardSetController?

From a List Button or Visualforce Page, I wanna redirect to a ListView after. Common, right? Life is great when we're dealing with Standard Controller: using view() method. What is the correct, ...
3
votes
1answer
5k views

Visualforce Page and standardController attribute in Apex Page

I am developing a Visualforce page which will be rendered when a Salesforce User arrives by clicking a specific Account. The Apex page looks something like this: <apex:page> <c:...
3
votes
1answer
66 views

Redirect returns a bad constructor error

What's wrong with this code? public PageReference goodResponse() { PageReference fwdMessage = new PageReference(Page.TLResponsePage); fwdMessage.setRedirect(true); return fwdMessage; } ...
3
votes
1answer
2k views

Getting Communities Url from PageReference

I have a VisualForce page that I would like to open in a new tab via Javascript. javascript (in VF page, called onClick) function myFunction(){ OpenInNewTab("{!url}"); } Apex controller ...
3
votes
2answers
22k views

Displaying ApexPages.Messages on redirected VisualForce Page

I hope this is a simple problem and I'm just missing something. My Controller is something like this public pagereference processtempcon(){ //some code here delete record; pagereference ...
3
votes
1answer
47 views

salesforce Pre fill value in create page

Is it possible that pre fill value on the create page example: public PageReference Create() { Contact tmp = new Contact (); tmp.Name ='test123'; return new apexPages.StandardController(tmp)....
3
votes
1answer
2k views

Does <lightning:navigation> support targeting Visualforce pages with URL parameters?

I'm working on a Lightning component that includes a button, whose purpose is to load a Visualforce page rendering a PDF cover sheet. I'd like to use the most current supported functionality, so I'm ...
3
votes
1answer
719 views

Wrong Url displayed after redirect to PageReference

Have some strange behavior of the URL that gets displayed in my browser after redirecting between pages with a shared controller. Reproducible Code public with sharing class FooController { ...
3
votes
2answers
339 views

How to pass Picklist value form one Visual Force page to another?

I have 2 visual force page that I need to pass value from each other. First visual force page is for opportunity edit page. In this page I have a picklist field called Type . Value of this field are ...
3
votes
1answer
3k views

Test Class not sending page reference

I have looked at many examples and even some questions asked in stack but I still cannot get my test class to send the Page reference over. When I look at my log, it shows that it enters my controller ...
3
votes
1answer
769 views

Save PDF Visualforce as attachment - mergefields not showing

I really need your help because I'm completely stuck. I want to render a PDF from a Contract in Salesforce, and save it as a record's attachment. I followed several tutorials and I created a PDF ...
3
votes
1answer
839 views

Command Button Page Reference Redirect Creates a URL with the Generated ID of the Element rather than the specified URL

I have a button that redirects to a PDF page where the same controller fills in the information for both. To accomplish this I've been using a Command Button that returns a page reference of the PDF ...
3
votes
1answer
291 views

PageReference: Redirect to built page

Can I build some XML or JSON in Apex and then redirect to it from a method that returns a PageReference object? public PageReference saveText() { PageReference p = new PageReference(...
3
votes
1answer
617 views

Error : System.PageReference Save() is referenced by Visualforce Page

I have a controller extention class and a visulforce page, VF page had a reference to a method call save in the extension class However, I renamed the method and the reference from VF page. My ...

1
2 3 4 5 6