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
Aman Singh ChhokarAman Singh Chhokar 

Choose particular Case RecordSet on a Visualforce Page based on a field value in Case (Querystring)

Hi,

I have a visualforce Page where I am using a table to show the basic Case details and in the last column I am showing the link to users from which they get redirected to another Visualforce Page which shows the details in the top Page block using a Fieldset. Now the problem is that My requirement is that based on the chosen Case Type (Type Picklist) the visualforce Page should select the particular Fieldset. I am passing the Case ID from the table visual force page in a Query string. If Type is A then Fieldset1 should be used and If Type is B then Fieldset2 should be used in CaseDetail Page. (fieldset Name is Case_Details in this Case but I want to use multiple fieldsets without having to create many similar visualforce pages)

Any Help would be much appreciated.

The visualforce page to show Case List is as follows (code snippet used):
 
<apex:pageBlock >
                                <div class="row">
                                           <div class="col-sm-8">
                                              <apex:selectList value="{!filterId}" size="1">
                                              <apex:actionSupport event="onchange" rerender="CaseLists"/>
                                              <apex:selectOptions value="{!listviewoptions}"/>
                                              </apex:selectList>
                                          </div>
                                </div>
                                    <div class="text-center">
                                        <ul class="pagination">
                                            <li><apex:commandButton action="{!first}" disabled="{!!hasPrevious}" value="<<" title="First" styleClass="btn btn-primary"/></li>
                                            <li><apex:commandButton action="{!previous}" disabled="{!!hasPrevious}" value="Previous" title="Previous" styleClass="btn btn-primary"/></li>
                                            <li><apex:commandButton action="{!next}" disabled="{!!hasNext}" value="Next" title="Next" styleClass="btn btn-primary"/></li>
                                            <li><apex:commandButton action="{!last}" disabled="{!!hasNext}" value=">>" title="Last" styleClass="btn btn-primary"/></li>


                                        </ul>
                                    </div>

                                    <apex:pageBlockTable value="{!Bill}" var="pid" styleClass="table table-striped" id="CaseLists">
                                        <apex:repeat value="{!$ObjectType.Case.FieldSets.Case_List}" var="f">
                                            <apex:column headerValue="{!f.Label}"  styleClass="listTable">{!pid[f]}
                                            </apex:column>


                                        </apex:repeat>
                                       
                                        <apex:column >

                                            <apex:facet name="header">Action</apex:facet>
                                            <div class="btn-group" style="color:#942d81">
                                                <a href="/apex/CaseDetail?id={!pid.Id}" role="button" class="btn btn-primary">View Details</a>
                                               
                                            </div>
                                        </apex:column>
                                    </apex:pageBlockTable>

                                </apex:pageBlock>

The visualforce page to show Case Details is as follows (Code Snippet Used, so just look inside the Panel-body):
 
<apex:page docType="html-5.0" showHeader="false" sidebar="false" cache="false" standardStylesheets="false" Standardcontroller="Case" >


<div class="panel-body">

                                <!--start of loop of field set-->
                                
                                   <apex:repeat value="{!$ObjectType.Case.FieldSets.Case_Details}" var="f">


                                    <apex:outputPanel styleClass="row" layout="block" rendered="MOD({!$ObjectType.Case.FieldSets.Case_Details},2)==0"/>


                                    <div class="col-lg-6 col-md-6 col-sm-12 col-xs-12" >
                                        <div class="bio-row">
                                            <span>{!f.label} </span>:  {!Case[f]}
                                        </div>
                                    </div>
                                    <apex:outputPanel rendered="MOD({!$ObjectType.Case.FieldSets.Case_Details},2)!=0" />

                                </apex:repeat>
                                  
                        
                                <!--End of loop of field set-->
                                  </div>

</apex:page>

 
Best Answer chosen by Aman Singh Chhokar
Nayana KNayana K
Assuming you are storing type in a variable (say, objCaseType).  On change of case type, rerender = "caseDetailsOp, caseListOp"
<apex:outputPanel id="caseDetailsOp">
<apex:repeat value="{!$ObjectType.Case.FieldSets.Case_Details}" var="f" rendered="{!objCaseType == 'SOMEVALUE'}">
..................................
</apex:repeat>
</apex:outputPanel>


<apex:outputPanel id="caseListOp">
<apex:repeat value="{!$ObjectType.Case.FieldSets.Case_List}" var="f" rendered="{!objCaseType == 'SOMEVALUE'}">
..................................
</apex:repeat>
</apex:outputPanel>



OR 
you can wrap both apex:repeats in one outputpanel and rerender this outputpanel on change of case type.
 

All Answers

Nayana KNayana K
Assuming you are storing type in a variable (say, objCaseType).  On change of case type, rerender = "caseDetailsOp, caseListOp"
<apex:outputPanel id="caseDetailsOp">
<apex:repeat value="{!$ObjectType.Case.FieldSets.Case_Details}" var="f" rendered="{!objCaseType == 'SOMEVALUE'}">
..................................
</apex:repeat>
</apex:outputPanel>


<apex:outputPanel id="caseListOp">
<apex:repeat value="{!$ObjectType.Case.FieldSets.Case_List}" var="f" rendered="{!objCaseType == 'SOMEVALUE'}">
..................................
</apex:repeat>
</apex:outputPanel>



OR 
you can wrap both apex:repeats in one outputpanel and rerender this outputpanel on change of case type.
 
This was selected as the best answer
Aman Singh ChhokarAman Singh Chhokar
Thank you Nayana. :)