+ Start a Discussion
lsateeshklsateeshk 

how to implement "Ëdit" button Functionality in visual force pages for custom object

hello all,

 

      I am new to developing.. So i would like t create implementation for all the buttons in standard objects that we can see... So far ihave done with Save, delete and i m looking for Edit button.. can any one help me in this regard? 

 

I have created custom object  in which i can enter new record and save it... once after saving if i want to edit the page, if i press edit button in detail page( ihave created custom detail page tooo) it has to take me to edit page in which the values that have entered earlier have to be shown in respective fields ... 

 

Please help me out... thank you 

 

 

Best Answer chosen by Admin (Salesforce Developers) 
HariDineshHariDinesh

Yes,

 

We can get the id dynamically.

 

IF you are using Visual force page and controller then use in controller

String stdid = ApexPages.currentPage().getparameters().get('id')

  

This will get the id of the record and save into the stdid. And use that not in the above code.

 

OR

In the constructor of the controller code like this

 

Public Student__c) temstud {get;set;}
temstud = (Student__c)controller.getRecord();

 

 Here you can get the id of the record by "temstud.id"

All Answers

HariDineshHariDinesh

Hi,

 

Get the record id and write like this in your method executed by Edit button 

 

PageReference Page = new PageReference(‘/’+ id of that record  +’/e’)

 

 If you want to controle ther redirection of page after saving then

 

PageReference Page = new PageReference(‘/’+that id of the record  +’/e’ +'&retURL=/' +  id of the record  );

 

 

lsateeshklsateeshk

Thanks for your reply..!!!!

 

I have another doubt.. you have mentioned "ïd of that record" is that will that take dynamically?

 

if yes can you explain me how?

 

let say object name is Student__c

 

thanks,

 

 

 

HariDineshHariDinesh

Yes,

 

We can get the id dynamically.

 

IF you are using Visual force page and controller then use in controller

String stdid = ApexPages.currentPage().getparameters().get('id')

  

This will get the id of the record and save into the stdid. And use that not in the above code.

 

OR

In the constructor of the controller code like this

 

Public Student__c) temstud {get;set;}
temstud = (Student__c)controller.getRecord();

 

 Here you can get the id of the record by "temstud.id"

This was selected as the best answer
lsateeshklsateeshk

Thank you SO much bro!!!