You need to sign in to do that
Don't have an account?
ArchanaR
render button next to a field set (conditionally) based on field set value
I want to render a button next to a field set conditionally based on field set value. How can I achieve that. For eg. in the code below, I want to render the button only if the column is "Bill To"
<apex:pageBlock id="systemDetails" title="System Details" >
<apex:pageBlockSection id="PBS" columns="2">
<apex:repeat value="{!$ObjectType.Opportunity.FieldSets.System_Information}" var="f">
<apex:outputField value="{!Opportunity[f]}"/>
<apex:commandButton value="Copy Bill To" rendered="{!Opportunity[f]='Bill To'}" action="{!copyBillTo}"/>
</apex:repeat>
</apex:pageBlockSection>
</apex:pageBlock>
"Bill To" is a field in the fieldset. This is not working. Any idea what could be the issue here.
You can reference the API name (or label and other attributes for that matter) for a field inside a Field Set as such:
<apex:repeat value="{!$ObjectType.Opportunity.FieldSets.System_Information}" var="f">
{!$ObjectType.Opportunity.Fields[f].name
</apex:repeat>
I tried to use that in a render condition though (i.e. rendered=" {!$ObjectType.Opportunity.Fields[f].name == 'My_Field__c'") and it didn't seem to work. Not sure why, but perhaps you can try some different combinations of that?
Use this , It works:
<apex:page standardController="Account">
<apex:form >
<apex:pageBlock >
<apex:repeat value="{!Account.contacts}" var="Conatcts">
<apex:repeat value="{!$ObjectType.Contact.FieldSets.Contact_Fields}" var="f">
<Br/><apex:outputlabel value="{!contains(lower($ObjectType.Contact.Fields[f].label),'bill to')}"/>
</apex:repeat>
</apex:repeat>
</apex:pageBlock>
</apex:form>
</apex:page>