1

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>`

Second VF Code:

 //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>
2

As you have already passed case id to second visualforce page you can have a SOQL in controller of second page to know Case type. You can store Case type in some string variable say caseType and use it in visualforce page as:

<apex:repeat value="{!$ObjectType.Case.FieldSets.Case_Details}" var="f" rendered="{!CaseType=='A'}">
.
.
</apex:repeat>
<apex:repeat value="{!$ObjectType.Case.FieldSets.Case_Details_2}" var="f" rendered="{!CaseType=='B'}">
.
.
</apex:repeat>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.