You need to sign in to do that
Don't have an account?
ArrgHunter
Updating custom field in visualforce page
I have built a visualforce page with custom controller. On my vf page I have 3 buttons. I want to update a custom field when a user clicks on one of the buttons and then want to redirect the user to different page.
Any idea what is the best way to achieve this.
Thanks,
//My custom controller class public class IRPTemplateSelection { public PageReference TemplateSelection() { String TemplateId = ApexPages.currentPage().getParameters().get('Templateid'); if (TemplateId == 'a0JP0000001qGwU') {Orphan__c.Biodata_Report_Template__c = 'a0JP0000001qGwU';} else if (TemplateId == 'a0JP0000001q86Q') {Orphan__c.Biodata_Report_Template__c = 'a0JP0000001q86Q';} else {Orphan__c.Biodata_Report_Template__c = 'a0JP0000001q86Q';} PageReference pageRef = new PageReference('https://cs4.salesforce.com/a0A?fcf=00B20000005raAO' ); pageRef.setRedirect(true); return pageRef; } }
VF Page <apex:page controller="IRPTemplateSelection" title="Template Selection" id="Templateselectionpage"> <!-- Begin Default Content REMOVE THIS --> <h1>Biodata Template Selection</h1> <apex:form id="allocOrphansForm" > <apex:outputPanel > <apex:pageBlock id="resultsBlock"> <apex:pageBlockButtons > <apex:commandButton title="Select BioData Template" value="English BioData Template" /> <apex:param name="Templateid" value="a0JP0000001qGwU" /> </apex:pageBlockButtons> <apex:pageBlockButtons > <apex:commandButton title="Select BioData Template" value="Arabic BioData Template" /> <apex:param name="Templateid2" value="a0JP0000001q86Q" /> </apex:pageBlockButtons> <apex:facet name="header">Choose Template</apex:facet> <apex:outputText value="template"> <apex:param value="test template" /> </apex:outputText> </apex:pageBlock> <apex:pageBlock title="Simple Title"> <b>Hello <i>{!$User.FirstName}</i>.</b> </apex:pageBlock> </apex:outputPanel> </apex:form> <!-- End Default Content REMOVE THIS --> </apex:page>
One way would be:
Every button calls another function which redirects the user to a different page.
If you want to use only one function try to use apex:params to tell the controller which button was pressed.
developer74.
the redirection will be to the same one page. i want to update the custom field and then redirect the users to oppertunities page.
am i missing anything from the code above.
note: i have changed redirection URL
thanks
i though it will be very simple thing.
am i missing anything? experts...