You need to sign in to do that
Don't have an account?
Abhishek Purohit
I have 2 vf pages and 1 custom controller want to add the record,save it on the visualforce page and database and redirect again to the 1st page please help .
this is vf3 page <apex:page controller="OppControl"> <apex:form > <apex:pageBlock title="Search The Opportunities"> Name: <apex:inputText value="{!key}"/> <apex:commandButton value="Go" action="{!search}"/> <apex:commandButton value="Add Opportunity " action="{!add}"/> <apex:pageBlockTable value="{!myop}" var="my"> <apex:column ><apex:outputLink value="/{!my.id}">"{!my.Name}"</apex:outputLink></apex:column> <apex:column value="{!my.StageName}"/> <apex:column value="{!my.Amount}"/> <apex:column value="{!my.CloseDate}"/> </apex:pageBlockTable> </apex:pageBlock> </apex:form> </apex:page> This one redirects from the add opportunity button <apex:page controller="OppControl"> <apex:form > <apex:pageBlock title="The New Opportunity"> <apex:pageBlockSection title="Section One"> <apex:outputText value="Enter The Name"></apex:outputText> <apex:inputText /> </apex:pageBlockSection> <apex:pageBlockSection title="Section Two"> <apex:outputText value="Enter The Amount"></apex:outputText> <apex:inputText /> </apex:pageBlockSection> <apex:pageBlockSection title="Section Three"> <apex:outputText value="Enter The Stage Name"></apex:outputText> <apex:inputText /> </apex:pageBlockSection> <apex:pageBlockSection title="Section Four"> <apex:outputText value="Enter The Closed Date"></apex:outputText> <apex:inputText /> <apex:commandButton value="Save it" action="{!save}"/> </apex:pageBlockSection> </apex:pageblock> </apex:form> </apex:page> This is my Custom Controller public class OppControl{ String key; List<Opportunity> myop; String SearchQuery{get;set;} public String getkey(){ return key; } public OppControl(){ myop=[Select Name,Amount,StageName,CloseDate From Opportunity]; } public List<Opportunity> getmyop(){ return myop; } public void setkey(String ip){ key=ip; } public PageReference search(){ SearchQuery='Select Name,StageName,Amount,CloseDate From Opportunity where Name like '+'\''+key+'%'+'\''; myop=database.query(SearchQuery); return null; } public PageReference add(){ return Page.vf4; } public PageReference save(){ return Page.vf3; } } Now I want to add the record like for real in the database using this controller and also after it has been saved on that vf4 page should be able to show the name stagename closedate amount on the vf3 page
Please find below code it will work.
Please let me know, if it helps you.
Best Regards,
Dayakar.D
All Answers
You must have to bind your input fields with your object instance to save record into database. First create an instace in your controller. like and use it into your vf page: Then in save method do DML on oppObj instance.
you have aleardy written the code to rediect it to first vf page:
Please look into below link for refrence : how to create Wizard in vf page:
https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_quick_start_wizard.htm
Please find below code it will work.
Please let me know, if it helps you.
Best Regards,
Dayakar.D
Now for the inline editing and the deletion operation how can i use it????also I want to take the stagename in picklist and the closed date in the date table format??the date box