You need to sign in to do that
Don't have an account?
gribis
How can I generate PageReferences to a specific view(e.g. New Contact) in VF controller APEX code?
I am trying to generate a PageReference to a new object, and pre-populate the object with some values. Additionally, I need to specify a return page. All this is doable in javacript or within the VF page.
Code:
...<apex:stylesheet value="{!URLFOR($Resource.pdfresources, 'styles.css')}"/>...
In APEX, the only way I got this to work is by specifying the URL in text...
Code:
PageReference lPr = new PageReference('/a0F/e—CF00N30000002qbnG='+EncodingUtil.urlEncode(this.lCase.Account.Name,'UTF-8')+'&CF00N30000002qbnG_lkid='+EncodingUtil.urlEncode(this.lCase.AccountId,'UTF-8')+'&saveURL='+EncodingUtil.urlEncode('/apex/CaseClusters–id='+EncodingUtil.urlEncode(this.lCase.Id,'UTF-8'),'UTF-8')+'&retURL='+EncodingUtil.urlEncode('/apex/CaseClusters˜id='+EncodingUtil.urlEncode(this.lCase.Id,'UTF-8'),'UTF-8'));
This does not migrate well from developement to production environment. But it works once the URL has been adapted to the target environment.
I did find some example related to the StandardController class that looked promissing, but did not work as expected. This will open the "case" record, not the "Cluster__c" object I intended it to.
Code:
Cluster__c theNewCluster = new Cluster__c(Account__c = this.lCase.AccountId); PageReference lPr = (new ApexPages.StandardController(theNewCluster)).edit();
Is there a better way to handle this in APEX code, where the URLs are created dynamically, environment independent?
Any input would be greatly appreciated.
Jeff Douglas
Informa Plc
blog.jeffdouglas.com
Here is the related VF page code:
This may be more than you asked for...
The "createNew" action is the element that I was experimenting with. The controller code has the working URL reference in it. What I tried was the following code without success: