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
Aditya Rayavarapu 5Aditya Rayavarapu 5 

Get Record ID

Hi, I created a visualforce page to create a case. Users can enter their name, email, etc, and click 'Submit case' which will create the case and also redirect to a new Thank You page which will provide them with the Case Number. 

I have been able to do this successfully, except for the final step of displaying the Case Number.

public pageReference save()
    {
        insert case;
         
        PageReference reRend = new PageReference('/apex/thankyoupage'); 
        reRend.setRedirect(false);
        return reRend;

Thanks!
James LoghryJames Loghry
You'll likely need to do a few things to get this to work:

Your VF page should use the Case StandardController and you should pass in the id of the case as an Http param.

For instance:  
 
PageReference reRend = new PageReference('/apex/thankyoupage?id='+case.Id);

Or better yet:
 
PageReference reRend = PageRef.ThankYouPage;
reRend.getParameters().put('id',case.Id);

Then your visualforce page should be able to render {!Case.CaseNumber} or whatever the field is.