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
Marketing Marketing 27Marketing Marketing 27 

how to show success message after VF pages navigates to new record

I've just made a basic wizard composed of two Visualforce pages. On the second page, users create a new opportunity of a specific type. When they click Save, they are taken to the newly created opportunity.

I would like a basic success message to pop up on this page after they are taken to it.

how can I accomplish this? I will make a lightning web component if I have to but I would rather not :) 

below is my save method on my controller extension
public PageReference Save(){

        try{
            insert TD2nd;
            TD1st.X504_Related_Opportunity__c = TD2nd.Id;
            update TD1st;
            return new Pagereference('/' + TD2nd.Id);           
        }
        catch(DmlException d){
            Apexpages.addMessages(d);
            return NULL;
        }
    }

 
VinayVinay (Salesforce Developers) 
Hi Marketing,

Check below syntax.
PageReference saveResult = std.save(); 
if(saveResult == null) 
{ 
return saveResult; // Errors will be displayed utomatically 
}
Check value from StandardController's save method

https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/apex_ApexPages_StandardController_methods.htm
https://www.infallibletechie.com/2018/09/how-to-display-success-message-on.html

Please mark as Best Answer if above information was helpful.

Thanks,