Skip to main content
added 23 characters in body
Source Link
mlpSFadmin
  • 597
  • 1
  • 7
  • 21

Can anyone help me to sort a field set that I'm iterating through with apex:repeat? I have a Visualforce page that renders some data as a PDF using Field Sets and I just want the ability to sort the Opportunities block by Close Date desc. (I also have a Task set that I aim to sort by Activity Date desc, but I imagine that will have the same answer as this, only posting one block for simplicity.)

My code snippet right now (standardController = "Account"):

<table id="Opportunities">
  <tr>
    <apex:repeat value="{!$ObjectType.Opportunity.FieldSets.Opp_Set}" var="f">
        <th class="tableHeader">{!$ObjectType.Opportunity.fields[f].Label}</th>
    </apex:repeat>
  </tr>
  <apex:repeat value="{!account.Opportunities}" var="opportunity">
    <tr>
      <apex:repeat value="{!$ObjectType.Opportunity.FieldSets.Opp_Set}" var="f">
        <td><apex:outputField value="{!opportunity[f]}"/></td>
      </apex:repeat>
    </tr>
  </apex:repeat>
</table>

FWIW: I'm self-taught admin who dabbles in development - I feel like I could probably figure this out with more time, but I'm under the wire and feeling the crunch of not being sure how to adapt this.

Looks like I can either go with some Javascript ala Sort Order of Child Records Using a Standard Controller, though I don't really understand how to adapt this to work with Field Sets (Field Sets were totally new to me with this project, so I might be making them out to be more impactful than they really are), or an extension or custom controller, which I just....really didn't want to have to do for this project and I'm being a baby haham honestly not quite sure how to do either.

Yes, I've already upvoted https://success.salesforce.com/ideaView?id=08730000000Brl4AAC though I encourage others to as well.

Thank you all in advance!

Can anyone help me to sort a field set that I'm iterating through with apex:repeat? I have a Visualforce page that renders some data as a PDF using Field Sets and I just want the ability to sort the Opportunities block by Close Date desc. (I also have a Task set that I aim to sort by Activity Date desc, but I imagine that will have the same answer as this, only posting one block for simplicity.)

My code snippet right now (standardController = "Account"):

<table id="Opportunities">
  <tr>
    <apex:repeat value="{!$ObjectType.Opportunity.FieldSets.Opp_Set}" var="f">
        <th class="tableHeader">{!$ObjectType.Opportunity.fields[f].Label}</th>
    </apex:repeat>
  </tr>
  <apex:repeat value="{!account.Opportunities}" var="opportunity">
    <tr>
      <apex:repeat value="{!$ObjectType.Opportunity.FieldSets.Opp_Set}" var="f">
        <td><apex:outputField value="{!opportunity[f]}"/></td>
      </apex:repeat>
    </tr>
  </apex:repeat>
</table>

FWIW: I'm self-taught admin who dabbles in development - I feel like I could probably figure this out with more time, but I'm under the wire and feeling the crunch of not being sure how to adapt this.

Looks like I can either go with some Javascript ala Sort Order of Child Records Using a Standard Controller, though I don't really understand how to adapt this to work with Field Sets (Field Sets were totally new to me with this project, so I might be making them out to be more impactful than they really are), or an extension or custom controller, which I just....really didn't want to have to do for this project and I'm being a baby hah.

Yes, I've already upvoted https://success.salesforce.com/ideaView?id=08730000000Brl4AAC though I encourage others to as well.

Thank you all in advance!

Can anyone help me to sort a field set that I'm iterating through with apex:repeat? I have a Visualforce page that renders some data as a PDF using Field Sets and I just want the ability to sort the Opportunities block by Close Date desc. (I also have a Task set that I aim to sort by Activity Date desc, but I imagine that will have the same answer as this, only posting one block for simplicity.)

My code snippet right now (standardController = "Account"):

<table id="Opportunities">
  <tr>
    <apex:repeat value="{!$ObjectType.Opportunity.FieldSets.Opp_Set}" var="f">
        <th class="tableHeader">{!$ObjectType.Opportunity.fields[f].Label}</th>
    </apex:repeat>
  </tr>
  <apex:repeat value="{!account.Opportunities}" var="opportunity">
    <tr>
      <apex:repeat value="{!$ObjectType.Opportunity.FieldSets.Opp_Set}" var="f">
        <td><apex:outputField value="{!opportunity[f]}"/></td>
      </apex:repeat>
    </tr>
  </apex:repeat>
</table>

FWIW: I'm self-taught admin who dabbles in development - I feel like I could probably figure this out with more time, but I'm under the wire and feeling the crunch of not being sure how to adapt this.

Looks like I can either go with some Javascript ala Sort Order of Child Records Using a Standard Controller, though I don't really understand how to adapt this to work with Field Sets (Field Sets were totally new to me with this project, so I might be making them out to be more impactful than they really are), or an extension or custom controller, which I just....really didn't want to have to do for this project and am honestly not quite sure how to do either.

Yes, I've already upvoted https://success.salesforce.com/ideaView?id=08730000000Brl4AAC though I encourage others to as well.

Thank you all in advance!

Source Link
mlpSFadmin
  • 597
  • 1
  • 7
  • 21

Sort field set in Visualforce renderAs PDF with apex:repeat

Can anyone help me to sort a field set that I'm iterating through with apex:repeat? I have a Visualforce page that renders some data as a PDF using Field Sets and I just want the ability to sort the Opportunities block by Close Date desc. (I also have a Task set that I aim to sort by Activity Date desc, but I imagine that will have the same answer as this, only posting one block for simplicity.)

My code snippet right now (standardController = "Account"):

<table id="Opportunities">
  <tr>
    <apex:repeat value="{!$ObjectType.Opportunity.FieldSets.Opp_Set}" var="f">
        <th class="tableHeader">{!$ObjectType.Opportunity.fields[f].Label}</th>
    </apex:repeat>
  </tr>
  <apex:repeat value="{!account.Opportunities}" var="opportunity">
    <tr>
      <apex:repeat value="{!$ObjectType.Opportunity.FieldSets.Opp_Set}" var="f">
        <td><apex:outputField value="{!opportunity[f]}"/></td>
      </apex:repeat>
    </tr>
  </apex:repeat>
</table>

FWIW: I'm self-taught admin who dabbles in development - I feel like I could probably figure this out with more time, but I'm under the wire and feeling the crunch of not being sure how to adapt this.

Looks like I can either go with some Javascript ala Sort Order of Child Records Using a Standard Controller, though I don't really understand how to adapt this to work with Field Sets (Field Sets were totally new to me with this project, so I might be making them out to be more impactful than they really are), or an extension or custom controller, which I just....really didn't want to have to do for this project and I'm being a baby hah.

Yes, I've already upvoted https://success.salesforce.com/ideaView?id=08730000000Brl4AAC though I encourage others to as well.

Thank you all in advance!