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
ishwarya ishuishwarya ishu 

after clicking save, the record should be displayed in new VF page. Anyone please send me a code

<apex:page standardController="Case" showHeader="false" >
    <apex:form >
        <apex:pageBlock title="Case Status">
            <apex:pageBlockSection columns="1">
                <apex:inputField value="{!Case.Status}"/>
                <apex:inputField value="{!Case.Reason}"/>
                <apex:inputField value="{!Case.Priority}"/>
            </apex:pageBlockSection>
            <apex:pageBlockButtons >
                <apex:commandButton action="{!save}" value="save"/> 
            </apex:pageBlockButtons>
        </apex:pageBlock>
    </apex:form>
</apex:page>

when giving reason and status for the case object and saving it. this saved record should be displayed in another new VF page
Kai Herng LauKai Herng Lau
Hi Ishwarya,

I believe your current code will redirect you to the newly created case record. If you would like to redirect to others page you might need to create a controller class. What is your new VF page?
ishwarya ishuishwarya ishu
Hiii kai herng,
It is saved in case object, but i need only this record should be displayed in a new page. i think this can be done using id. but i dont know .
WEN JIEWEN JIE
As your code, when you click save button, you will go to case detail page. Do you want to go to your VF page ?
Suraj TripathiSuraj Tripathi

Hi ishwarya ishu,

please try this for your need. Hope it will help you.

Vf Page 1

<apex:page showHeader="false" controller="TestVfApx">
    <apex:form >
        <apex:pageBlock title="Case Status">
            <apex:pageBlockSection columns="1">
                <apex:inputField value="{!caseobj.Status}"/>
                <apex:inputField value="{!caseobj.Reason}"/>
                <apex:inputField value="{!caseobj.Priority}"/>
            </apex:pageBlockSection>
            <apex:pageBlockButtons >
                <apex:commandButton action="{!saveButton}" value="save"/> 
            </apex:pageBlockButtons>
        </apex:pageBlock>
    </apex:form>
</apex:page>


Vf Page 2

<apex:page controller="TestVfApx">
    <apex:pageBlock>
    	<apex:pageBlockTable value="{!caseList}" var="cs">
        	<apex:column value="{!cs.Status}"/>
            <apex:column value="{!cs.Reason}"/>
            <apex:column value="{!cs.Priority}"/>
        </apex:pageBlockTable>
    </apex:pageBlock>
</apex:page>


Apex controller

public class TestVfApx {
    public Case caseobj {get;set;}
    public List<Case> caseList {get;set;}
    public String Idkey {get;set;}
    public TestVfApx(){
        caseobj = new Case();
        Idkey = ApexPages.currentPage().getParameters().get('id');
        if(Idkey != null){
            caseList = [select Id, Status, Reason, Priority from case where id=:Idkey limit 1];
        }
    }
    public PageReference saveButton(){
        insert caseobj;
        System.debug(caseobj);
        PageReference pr = new PageReference('/apex/Test2VF?&id='+caseobj.Id);
        pr.setRedirect(true);
        return pr;
    }
    
}


Mark as a best if it will help you.

Regards,

Suraj

ashishashish
HI,
Through Page Refernce you can Rediret to ur exiting vf page ,:
public PageReference redirect(){
        
        PageReference pg=new pageReference('/apex/sample');
        return pg;
    }

here 'sample' is name of the vf page ,
this Redirect Method will be called from Redirect button on Vf page
<apex:commandButton value="redirect" action="{!redirect}"/>

thanks,
please mark it as a best answer if it solves the problem.
 
Iswarya SekarIswarya Sekar
what should i use in case of standard controller?
ashishashish
Standard Controllers takes Standard Objects like 'Account , Lead, Opportunity, or Contact etc ' , use them according to your requirement 
iswarya sekar 7iswarya sekar 7
ok thank you!!