You need to sign in to do that
Don't have an account?
Rocio Vivanco
Error by passing parameters from one Visualforce page to another
Hi all,
I am trying to pass a parameter from one Visualforce to another.
I need to display / filter opportunities to an Account I gave in the first visualforce.
Here is the part where I declare the "passing" of the AccountId to the second visualforce:
In my second Visualforce "Visit_Report_with_Opportunities" I am referencing that parameter in order to show only the opportunities to that account:
Is there here something missing?
I am trying to pass a parameter from one Visualforce to another.
I need to display / filter opportunities to an Account I gave in the first visualforce.
Here is the part where I declare the "passing" of the AccountId to the second visualforce:
public PageReference GoTo_VRWithOptys (){ string value = 'accountId'; string url; url = '/apex/Visit_Report_with_Opportunities?param1=' + accountId; PageReference pageRef = new PageReference(url); pageRef.setRedirect(true); return pageRef; }
In my second Visualforce "Visit_Report_with_Opportunities" I am referencing that parameter in order to show only the opportunities to that account:
<apex:pageBlock id="pagination" title="Opportunity Details"> <apex:pageBlockTable value="{!param1}" var="o" > <apex:column value="{!o.Name}"/> <apex:column value="{!o.CloseDate}"/> <apex:column value="{!o.Amount}"/> <apex:column value="{!o.CloseDate}"/> </apex:pageBlockTable>The apex to the second Visualforce page looks like this:
public String optyquery; public String name {get;set;} public Date closedate {get;set;} public Boolean fetchCalled {get;set;} public integer totalRecs {get;set;} private integer index = 0; private integer blockSize = 5; Id param1 {get;set;} String param_value {get;set;} public PaginationWithFilter() { param_value = System.CurrentPageReference().GetParameters().get('param1'); totalRecs = [select count() from Opportunity where Days_since_created__c <=365 and Account.Id =: param1]; fetchCalled = false; } public void fetch() { optyquery = 'SELECT Name, CloseDate FROM Opportunity where Days_since_created__c <=365 and Account.Id =: param1 '; List<Opportunity> tempopty = Database.Query(optyquery); totalRecs = tempopty.size(); optyquery += ' LIMIT ' + blockSize + ' OFFSET ' + index; fetchCalled = true; } public List<Opportunity> getOpty() { List<Opportunity> optys; if(fetchCalled) { fetch(); } else { optyquery = 'SELECT Name, CloseDate FROM Opportunity where Days_since_created__c <=365 and Account.Id =: param1 LIMIT : blockSize OFFSET : index'; } optys = Database.Query(optyquery); System.debug('Values are ' + optys); return optys; }When I try to save the second visualforce, the error I get is:
Error: Unknown property 'param1' referenced in Visit_Report_with_OpportunitiesI also tried replacing "param1" by "accountId" but the error then says:
Error: Unknown property 'accountId' referenced in Visit_Report_with_Opportunities
Is there here something missing?
Why are you using custom pagination? You can use standard salesforce pagination. Your code is not optimized and need to refacrtored it as some of the variables not required. Anyway, you can try this -
Thanks,
Sumit Kumar Singh
I have looked into your code. It looks fine.
param1 is the correct way to access.
I hope you directly opened the page2 or may be you haven't passed parameter properly from the vf page 1.
Try this
use this url at the top of the browser.. if the code works ,thinks are fine ..problem is in passing variable from vf1 controller.
salesforceURLinstance/apex/Visit_Report_with_Opportunities?param1= (replace with opportunity id that exists in your org) Let me know if you need further help.
Thanks and Regards,
Shiva RV.