+ Start a Discussion
sfdc@isha.ax1814sfdc@isha.ax1814 

action status onchange sections should display

Hi Team,

I have a Req that on cas estandard page based on the status value need to display the different fieds.

Status='Working'--> Text1 Text 2 fields should display.
Status='Escalate'--> Text3 Text4 fields should display.

On save of this values it should be saved on the case . Please suggest me how can acheive this.

My Current page:

<apex:pageBlock >
<apex:pageblockSection >
  <apex:inputfield value="{!Case.Status}">
    <apex:actionSupport event="onchange" reRender="theForm" />
</apex:inputField>

  <apex:inputField value="{!Case.NewText1__c}" rendered="{!IF(Case.Status == 'Escalated',true,false)}"/>
  <apex:inputField value="{!Case.New_Text2__c}" rendered="{!IF(Case.Status == 'Escalated',true,false)}" />
  
  <apex:inputField value="{!Case.Working_1__c}" rendered="{!IF(Case.Status == 'Working',true,false)}" />
  <apex:inputField value="{!Case.Working_2__c}" rendered="{!IF(Case.Status == 'Working',true,false)}" />
  
   </apex:pageblockSection>
<apex:pageblockbuttons >
<apex:commandButton value="save" action="{!save}"/>

</apex:pageblockbuttons>
</apex:pageBlock>
</apex:form>

</apex:page>


Please help me on save and any changes on the code.


Regards,
Isha 

 
Khan AnasKhan Anas (Salesforce Developers) 
Hi Isha,

Greetings to you!

Below is the sample code which I have tested in my org and it is working fine. Kindly modify the code as per your requirement.
<apex:page standardController="Case">
    
    <apex:form id="theForm">
        
        <apex:pageBlock >
            <apex:pageblockSection >
                <apex:inputField value="{!Case.Status}">
                    <apex:actionSupport event="onchange" reRender="theForm"/>
                </apex:inputField>
            </apex:pageblockSection>
        </apex:pageBlock>
        
        <apex:pageblock >
            <apex:pageblockSection rendered="{!Case.Status = 'Working'}">
                <apex:inputField value="{!Case.Working_1__c}"/>
                <apex:inputField value="{!Case.Working_2__c}"/>
            </apex:pageblockSection>
            
            <apex:pageblockSection rendered="{!Case.Status = 'Escalate'}">
                <apex:inputField value="{!Case.NewText1__c}"/>
                <apex:inputField value="{!Case.New_Text2__c}"/>
            </apex:pageblockSection>
            
            <apex:pageblockbuttons >
                 <apex:commandButton value="Save" action="{!save}"/>
            </apex:pageblockbuttons>
            
        </apex:pageblock>
    </apex:form>
</apex:page>

I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.

Thanks and Regards,
Khan Anas
Ajay K DubediAjay K Dubedi
Hi Isha,
Please try the below code and let me know if this works for you. If still need modifications do let me know.
 
<apex:page controller="demo">
    <apex:form id="theForm">
        <apex:pageBlock >
            <apex:pageblockSection >
                <apex:inputField value="{!cs.Status}">
                    <apex:actionSupport event="onchange" reRender="theForm"/>
                </apex:inputField>
            </apex:pageblockSection>
        </apex:pageBlock>
        <apex:pageblock >
            <apex:outputPanel rendered="{!cs.Status = 'Working'}">
                <apex:pageblockSection >
                    <apex:inputField value="{!cs.Id}"/>
                    <apex:inputField value="{!cs.Status}"/>
                </apex:pageblockSection>
            </apex:outputPanel>
            <apex:outputPanel  rendered="{!cs.Status = 'Escalate'}">
                <apex:pageblockSection>
                    <apex:inputField value="{!cs.Status}"/>
                    <apex:inputField value="{!cs.Id}"/>
                </apex:pageblockSection>
            </apex:outputPanel>
            <apex:pageblockbuttons >
                <apex:commandButton value="Save" action="{!save}"/>
            </apex:pageblockbuttons>
        </apex:pageblock>
    </apex:form>
</apex:page>

Controller:
public class Demo {
 public Case cs{get;set;}
    public Demo(){
        cs = [SELECT Status,OwnerId FROM Case limit 1];
    }
    public void save() {}
}



I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks,
Ajay Dubedi
sfdc@isha.ax1814sfdc@isha.ax1814
Hi Thank you so much for your eply.

Is there any other way to acheive my requirement with out coding/vfpage.


My Req: On the Case standard page based on the status change fields should display given like above?

If with vfpage is my solution  it should be inline vfpage. After saving iam getting like below. Please guide  me.

User-added image

Regards,
Isha