function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
ani123ani123 

Previous content stored in vf page after save

Hi ,

i have a visual force page for an custom object ,the vf page opens by an tab, WHEN the vf page opens need to fill the info on click the save button the data will save to custom obj__c. but after saving the page will redirect to same vf page.

 

But if i want to create a new record in vf page by clicking on the Tab ,the previous data is displaying.Each time if i want to create record showing previous data info  in vf page.

SUGGEST ME SOLUTION AS SOO AS POSSIBLE

Shashikant SharmaShashikant Sharma

If you want to show previous data then in your save method should be of PageReference return type

And return this

 

return ApexPages.currentPage();

 

 

If you don't want  to show previous data then do this 

 

 

PageReference pg = new PageReference(Page.YourPageName.getUrl());
pg.setRedirect(true);
return pg; 

 

 

 

 

ani123ani123

Hi Shashikant Sharma ,

i have tried with that code but i am facing same problem

Shashikant SharmaShashikant Sharma

Please provide your class and page code, it would be helpful for me to figure out the issue.

ani1ani1

this is my apex class when i create a new record in vf page i found the row which i add before

Shashikant SharmaShashikant Sharma

If you are using savetimesheet method then there is no isue with retun statement now , but I think you are getting any exception so its returning from catch,  

 

Use 

ApexPages.addMessages(e); in catch block and add a <apex:pageMessages />

in VFP to see error

 

for once for test copy the same returning url code in catch block also then check.

ani1ani1

I have changed the folloe\wing u mentioned but i am receiving same error

ani1ani1

onclick Cancel the Previous data in vf page s getting cleared bt i want the same whenever i create a new record old record should nt populate