You need to sign in to do that
Don't have an account?
Irene Sless
Change current record id in URL in Visualforce page
I have 2 buttons that toggle between 2 different views (detail and list) of an object (ie all calls for a sales rep) using the sam Controller for both.
In the list view the sales rep or the date can be changed to retrieve for another rep or for another date. When I click the toggle button however to display the detail view again, it displays the original record selected, not the new one I selected in the list view, as the ID parameter in the URL doesn't change when I select a new record.
How do I get it to change the ID in the URL to the latest one, or to pick it up regardless of the URL parameter? In my commandbutton I put in the new ID as below, yet when it loads the detail view through the controller it loads the old one.
In the list view the sales rep or the date can be changed to retrieve for another rep or for another date. When I click the toggle button however to display the detail view again, it displays the original record selected, not the new one I selected in the list view, as the ID parameter in the URL doesn't change when I select a new record.
How do I get it to change the ID in the URL to the latest one, or to pick it up regardless of the URL parameter? In my commandbutton I put in the new ID as below, yet when it loads the detail view through the controller it loads the old one.
<apex:commandButton id="CCActivitiesView" action="{!view}" title="Call Cycle Activities View" value="Call Cycle Activities Detail View" onclick="location.href=('/apex/CallCycleView?id={!CallCycle.Id}')" />And the code in my Controller is as follows:
public CallCycleController(ApexPages.StandardController std) { stdCtrl=std; CallCycle = (CallCycle__c)std.getRecord(); date ccDate = CallCycle.Date__c; if(CallCycle != null && CallCycle.Id != null){ CallCycle = [Select Id, OwnerId, Name, Date__c, CycleStart__c, CycleEnd__c, SalesPerson__c, SalesPerson__r.Name From CallCycle__c Where Id = :CallCycle.Id]; LoadModel(); }I've been looking for an answer to this for a while and one person suggested 'move the redirection code into server side', but I don't know what's meant by that (have asked but no reply and am getting a bit more desperate now).
Another observation you have specified “Action” and “onclick” attribute on commandbutton, which is incorrect you should utilize either, preferably action , in method called through action return PageReference.
All Answers
Another observation you have specified “Action” and “onclick” attribute on commandbutton, which is incorrect you should utilize either, preferably action , in method called through action return PageReference.