You need to sign in to do that
Don't have an account?

How can i get the information from apex controller to visualforcepage ?
I want to go straight to a solution record type without being need to select the record type. When i check the url i see that opp name it is different than the one from where i started the solution.
Here is my visualforcepage
<apex:page standardController="Solutions__c" recordSetVar="solutions" extensions="SolutionWrapper" >
<script>
function redirect(){
window.location.href='/a0A/e?CF00ND0000005pODo={!opp.Name}&CF00ND0000005pODo_lkid={!opp.Id}&retURL=%2F{!opp.Id}&RecordType=012D00000007LTY&Opportunity__c={!opp.Name}&Solution_Country__c={!sol.Solution_Country__c}={!acc.Country__c}&ent=01ID0000000uXce';
}
window.onload = window.setTimeout(redirect(),5000);
</script>
</apex:page>
Controller :
public with sharing class SolutionWrapper {
public Opportunity opp{get; set;}
public Solutions__c oppId{get; set;}
public Solutions__c sol{get; set;}
public Solutions__c solution{get; set;}
public Account acc{get; set;}
public SolutionWrapper(ApexPages.StandardSetController controller) {
try{
solution = new Solutions__c();
solution = (Solutions__c)controller.getRecord();
if(solution.Id != null){
oppId = [SELECT id, Solutions__c.Opportunity__c,Mail_Merge_Id__c
FROM Solutions__c
WHERE id =: solution.id
OR Mail_Merge_Id__c =: solution.Mail_Merge_Id__c
LIMIT 1];
opp = [Select id,Name, AccountId, CurrencyIsoCode from
Opportunity where id =: oppId.Opportunity__c LIMIT: 1];
}
if(opp.id !=null){
sol = [SELECT id,Name, Mail_Merge_Id__c,Solution_Country__c, Solutions__c.Opportunity__c
FROM Solutions__c
WHERE Solutions__c.Opportunity__c =: opp.id
LIMIT 1];
acc = [Select id,Name,Country__c from
Account where id=:opp.AccountId LIMIT: 1];
}
}
catch(Exception e){
ApexPages.addMessage(new ApexPages.message(ApexPages.Severity.ERROR,e.getMessage()));
}
}
}
Here is my visualforcepage
<apex:page standardController="Solutions__c" recordSetVar="solutions" extensions="SolutionWrapper" >
<script>
function redirect(){
window.location.href='/a0A/e?CF00ND0000005pODo={!opp.Name}&CF00ND0000005pODo_lkid={!opp.Id}&retURL=%2F{!opp.Id}&RecordType=012D00000007LTY&Opportunity__c={!opp.Name}&Solution_Country__c={!sol.Solution_Country__c}={!acc.Country__c}&ent=01ID0000000uXce';
}
window.onload = window.setTimeout(redirect(),5000);
</script>
</apex:page>
Controller :
public with sharing class SolutionWrapper {
public Opportunity opp{get; set;}
public Solutions__c oppId{get; set;}
public Solutions__c sol{get; set;}
public Solutions__c solution{get; set;}
public Account acc{get; set;}
public SolutionWrapper(ApexPages.StandardSetController controller) {
try{
solution = new Solutions__c();
solution = (Solutions__c)controller.getRecord();
if(solution.Id != null){
oppId = [SELECT id, Solutions__c.Opportunity__c,Mail_Merge_Id__c
FROM Solutions__c
WHERE id =: solution.id
OR Mail_Merge_Id__c =: solution.Mail_Merge_Id__c
LIMIT 1];
opp = [Select id,Name, AccountId, CurrencyIsoCode from
Opportunity where id =: oppId.Opportunity__c LIMIT: 1];
}
if(opp.id !=null){
sol = [SELECT id,Name, Mail_Merge_Id__c,Solution_Country__c, Solutions__c.Opportunity__c
FROM Solutions__c
WHERE Solutions__c.Opportunity__c =: opp.id
LIMIT 1];
acc = [Select id,Name,Country__c from
Account where id=:opp.AccountId LIMIT: 1];
}
}
catch(Exception e){
ApexPages.addMessage(new ApexPages.message(ApexPages.Severity.ERROR,e.getMessage()));
}
}
}
if you are talking about , how to bring OppId to VF Page from Controller, it can be done by
{!oppId}
---
Also I notice in the url
&Opportunity__c={!opp.Name}
I think you should be using
&Opportunity__c={!opp.Id}
by the way , a better way to redirect from vf page to different page is as below.
public PageReference GoToURL{
//Your logic here to fram url string.
PageReference retURL = new PageReference('REDIRECT URL');
retURL.setRedirect(true);
return retURL;
}
and call this pagereference from your <apex: page tag as below
<apex:page ....other parameters here--- action="{!GoToURL}">
Hope this helpw.
thanks
Jay