12 votes
Accepted

Putting parameters into PageReference

You have to use setRedirect(true); in your controller as below. Hope this helps. public PageReference saveNextResponse(){ //doing a DML as well pageRef = new PageReference('/apex/Question'); ...
Saroj Bera's user avatar
  • 14.6k
9 votes
Accepted

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

Through attempting this same problem on another project I was able to get a fresh look at the issue. What I learned through countless testing is that rerender attribute can be very tricky. For example:...
Xtremefaith's user avatar
  • 4,520
9 votes
Accepted

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

Wooooow, I finally figured it out. Changing { type: 'comm__namedPage', attributes: { pageName: yourPageName } } to { type: 'comm__namedPage', attributes: { ...
Luke's user avatar
  • 413
7 votes
Accepted

PageReference assertion error?reasons?

In Salesforce URL parameters are automatically encoded so if you want to assert the url replace your assert statement with following statement where EncodingUtil.urlEncode method is used to encode the ...
Himanshu's user avatar
  • 10.5k
7 votes
Accepted

Urban Legend? Must Return PageReference To Rerender

Analysis Conclusion You do not need to return a PageReference for rerender to understand when the action has completed. So if you have a method that will never cause a redirect, you can make it void ...
Adrian Larson's user avatar
  • 149k
7 votes
Accepted

Why does this PageReference take me to the wrong page?

The "apex" resource URL ignores path names, and only uses the last file name on the path. I tested this in my org with: /apex/pages/TestPage And it resolved to: /apex/TestPage I actually didn't ...
sfdcfox's user avatar
  • 481k
6 votes
Accepted

How to call a PageReference from a Constructor

You can't return a PageReference from a constructor, but you can use an action method when the page loads: <apex:page controller="SampleController" action="{!samplepage}" ... This will have the ...
sfdcfox's user avatar
  • 481k
6 votes
Accepted

Why does my returned PageReference not work

Your issue is probably down to validation on the page, when validation (required fields or errors) happen they block buttons from firing their actions, for actions where you don't want validation to ...
thegogz's user avatar
  • 368
6 votes
Accepted

Ignore Duplicate Results Alerts for Visualforce Page

You need to use the DmlOptions.DuplicateRuleHeader class. The isAllowSave method is used to determine if a rule allows saving or not (e.g. provide a warning or an error). The following modification ...
sfdcfox's user avatar
  • 481k
5 votes
Accepted

Id Value is not valid for standard controller

Looks like Id is null in your else case, so this.test record was not inserted. Record does not have an Id until it is inserted in the database. Make sure you insert your record before that else ...
Oles Malkov's user avatar
  • 2,161
5 votes
Accepted

The CORRECT way to redirect to a ListView from StandardSetController?

Whoa. This works: public PageReference listView() { return new ApexPages.Action('{!List}').invoke(); //System.PageReference[/a09?fcf=00B24000004cfLK] } But is it documented?
Matt and Neil's user avatar
5 votes
Accepted

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

As I attempted storing a custom record through another PageReference call within a component I got the following error: System.LimitException: DML currently not allowed While searching for answer I ...
Xtremefaith's user avatar
  • 4,520
5 votes

Bell icon in communities: syntax of the setTargetPageRef string?

I could see it working (outside of Communities, I have not tried that part yet) with the following scenarios: Named Page Type (type = standard__namedPage): quite limited but useful. Item Page Type (...
Jeferson Chaves's user avatar
4 votes

VF controller redirect to another page

You can use cookies Set cookie Cookie elementMsg = new Cookie('msg','true','/apex/pageYouAreGoingToUse',10,false); Add to the current page ApexPages.currentPage().setCookies(new Cookie[]{...
Ruwantha's user avatar
  • 251
4 votes
Accepted

PageReference not redirecting inside another method

You need to return that PageReference. You can't do anything after the return. public PageReference save() { // do stuff return done(); } I would also change the way you build the redirect ...
Adrian Larson's user avatar
  • 149k
4 votes
Accepted

The page you submitted was invalid for your session

The problem is with this line here param.putAll(ApexPages.currentPage().getParameters()); and in particular with the save_new parameter that is being added to the URL causing the error. Similar issue ...
Jenny B's user avatar
  • 10.5k
4 votes
Accepted

Identify the current page name

You can parse the URL to get the name of the current page. String pageName = ApexPages.currentPage().getUrl() .substringAfter('/apex/').substringBefore('?');
Adrian Larson's user avatar
  • 149k
4 votes
Accepted

Pass a parameter without exposing ids

You can do one of two things: Set redirect to false. The URL in the browser should not be updated. Could cause issues depending on the circumstances and the page redirected to must be using the same ...
Eric's user avatar
  • 54k
4 votes
Accepted

PageReference redirect

No, you can't redirect from a trigger. You'd have to create a Visualforce page to call the code and then perform your redirect. Also, you should always use StandardController to redirect: return new ...
sfdcfox's user avatar
  • 481k
4 votes
Accepted

How to assert on pagereference where the endpoint of pagereference is predefined

I tend to use .getUrl() and .startsWith() e.g. System.assert(nextPage.getUrl().startsWith(Page.ExpectedPage.getUrl()), nextPage.getUrl()); It's good to use startsWith() in case the controller puts ...
Aidan's user avatar
  • 13.5k
4 votes

How to assert on pagereference where the endpoint of pagereference is predefined

When you compare 2 objects in Salesforce (as far as it is known it is based on Java), it actually compares not objects, but their hashCode results, or what is returned as compareTo method from ...
kurunve's user avatar
  • 4,279
4 votes
Accepted

Why does string.replace fail with char codes?

You should use EncodingUtil class instead of replacing manually. For example: https%3A%2F%2Fdeveloper.salesforce.com%2Fdocs%2Fatlas.en-us.apexcode.meta%2Fapexcode%2Fapex_classes_restful_encodingUtil....
salesforce-sas's user avatar
4 votes
Accepted

LWC URL reading parameters

The State parameter of the URL addressable component using pagereference always needs a namespace. For normal orgs c is the namespace and hence you will need to make sure within the URL parameter you ...
Mohith Shrivastava's user avatar
4 votes
Accepted

What difference does the __c make in currentPageReference in code?

Previously, you could just use keyword, but in order to tighten security, it was changed so that you would need to include the "namespace" as part of the state. For unmanaged code, this is ...
sfdcfox's user avatar
  • 481k
3 votes
Accepted

Why can't VF detect my return statement?

Public Pagereference quickSave(){ Boolean first = false; for(Rights_Tracker__c RT : RightsTrackerList) { if(RT.Actual__c > RT.Agreement__c) { first = ...
Ratan Paul's user avatar
  • 22.5k
3 votes
Accepted

Redirect returns a bad constructor error

Just change your declaration to: PageReference redirect = Page.MyPage; You can't pass a PageReference into the PageReference constructor, which you are trying to do.
Adrian Larson's user avatar
  • 149k
3 votes
Accepted

How to Grab URL/Id of Newly Created Record

You have two insert statement into your code insert WT; insert fItem; You can get both record id by WT.id and fItem.id and you can build url for both item in following way before return ...
Himanshu's user avatar
  • 10.5k
3 votes

Create a record in Edit mode

You are not specifying in your URL which object you want to create the new Record for. So assuming it is Account, it should be PageReference('\001\e?retURL='+Apexpages.currentPage().getParameters()....
AslamK's user avatar
  • 2,079
3 votes

Visualforce Page redirect not working from apex actionfunction

try <apex:commandButton value="Create" onclick="createfunction(); return false;" />
Emma's user avatar
  • 31
3 votes
Accepted

Get multiselect field values (selected) values from one vf page to another

Follow the below approach Have single controller class to have logic from both visualforce pages. If Page has standard controller use that class as extension Since controller is same you will not ...
Ashwani's user avatar
  • 22.6k

Only top scored, non community-wiki answers of a minimum length are eligible