You need to sign in to do that
Don't have an account?
Ola Bamidele
How to Link the Save button to a URL
Hi All,
How can i link my VF Save button to a URL so that when a record in saved in my form, the user is redirectd to "www.google.com". Ive tried looking on different forms but other situations is always different to mine. Thanks for your help!
his is a snippet of my code.
<apex:page standardController="Turndown__c" sidebar="false" showHeader="true" extensions="pagereference" >
<apex:form >
<apex:pageBlock title="Documented Turndowns" id="turndown_list">
<apex:pageBlockSection columns="1" >
<!-- to remove the header, but keep the fields' help texts -->
<style type="text/css">
.bPageHeader {display: none;}
</style>
<!-- Inputfields -->
<apex:inputfield value="{! Turndown__c.Account__c }"/>
<apex:inputfield value="{! Turndown__c.Phone_Number__c }"/>
<apex:inputfield value="{! Turndown__c.Region__c }"/>
</apex:pageBlockSection>
<apex:pageBlockButtons >
<apex:commandButton action="{!Save}" value="Save" />
</apex:pageBlockButtons>
</apex:pageBlock>
</apex:form>
</apex:page>
Thanks again!
How can i link my VF Save button to a URL so that when a record in saved in my form, the user is redirectd to "www.google.com". Ive tried looking on different forms but other situations is always different to mine. Thanks for your help!
his is a snippet of my code.
<apex:page standardController="Turndown__c" sidebar="false" showHeader="true" extensions="pagereference" >
<apex:form >
<apex:pageBlock title="Documented Turndowns" id="turndown_list">
<apex:pageBlockSection columns="1" >
<!-- to remove the header, but keep the fields' help texts -->
<style type="text/css">
.bPageHeader {display: none;}
</style>
<!-- Inputfields -->
<apex:inputfield value="{! Turndown__c.Account__c }"/>
<apex:inputfield value="{! Turndown__c.Phone_Number__c }"/>
<apex:inputfield value="{! Turndown__c.Region__c }"/>
</apex:pageBlockSection>
<apex:pageBlockButtons >
<apex:commandButton action="{!Save}" value="Save" />
</apex:pageBlockButtons>
</apex:pageBlock>
</apex:form>
</apex:page>
Thanks again!
Replace update turnd; by Insert turnd;
Updated code;
All Answers
First of all you need to create a extension ( apex class ) for your page and in that you can create one method like: and call this method in your vf page save method like action="{!save}"
Thanks,
Neetu
Thanks for your reply. I created an apex class called "pageReference" however when i add the Save and brackets to that line, an error occurs. (Invalid constructor name: save).
Also, could you explain a bit more what you mean by Perform the steps to the save record?
Again thanks very much!
Pagereferece is a defined kayword in apex. you need to change your class name.
your extension will be like this.
Thanks for the information, i've now changed the class name to "RDT" and ive added an extension to the <apex:page>.with the new class name in my visualforce page.
However now on the VF page, its saying "Apex class RDT does not exist." Did i do something wrong because it shouldnt be saying that as i have created the apex class page successfully?
Thanks very much for the help!
When you use the extensions="extencntrl" then you must need to create the apex class of Name extencntrl.
Please check below code.
VF Page: Extension:
Thanks that makes sense, I made the changes. However, i'm getting this error after I click the save the button on the form:
"Update failed. First exception on row 0; first error: MISSING_ARGUMENT, Id not specified in an update call: []
Error is in expression '{! Save}' in component <apex:commandButton> in page visualforceturndowntesting: Class.extencntrl.save: line 10, column 1
"
So can i ask what you mean by "steps to save record" in the apex page? Because I know this is the problem why its not saving.
Thanks very much!
Replace update turnd; by Insert turnd;
Updated code;
It worked like a charm! Thanks very much for your help, much appreciated!
Thanks,
Ola