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
DevelopementDevelopement 

Show field from Oppy products

Hi All,

I have checkbox field on oppy product that is a formula field. I have created  a section for it in VF component. I want checbox "ONG" is checked on any one product . it should show

ONGS : Yes

But currently as per my belwo code, if oppy has 2 products and on product it is checked and on other it is not then it shows

ONGS: Yes
ONGS: No

I want if i have atleast 1prouct where ONG is checke, it should yes/. How to fix the below code.
<table border="1" cellpadding="2" cellspacing="0" style="border-collapse: collapse" bordercolor="#C0C0C0" width="100%">
                        <tr bgcolor="e1e1e1">
                                 <td colspan="2" valign="top" class="emailcopy"><strong>ONG</strong><strong></strong></td>
                        </tr>
                                       
                        
                        <apex:repeat value="{!objOpp.OpportunityLineItems}" var="c" >
       
                        
                         <tr>
                                 <td width="37%" valign="top" class="emailcopy">ONGS</td>
                                 <td width="63%" align="left" valign="top" class="emailcopy">{!IF(!c.ONG__c=True,'Yes','No')}</td>
                            </tr>
    </apex:repeat>
                    
                             
</table>

 
Best Answer chosen by Developement
pconpcon
Then what you are trying to do cannot be done without a controller and more logic inside.  You will want to iterate through each OpportunityLineItem in your controller and generate your Boolean and use that Boolean on your visualforce page.

All Answers

pconpcon
I beleive your problem lies in the fact that you are using the exclaimation point.  This will negate the value of the ONG__C field.  I would try
 
<td width="63%" align="left" valign="top" class="emailcopy">{!IF(c.ONG__c,'Yes','No')}</td>

Since it is a Boolean value you do not need to compare it to True
DevelopementDevelopement
but this still gives me 2 rows. 
User-added image

I want when an Opportunity has more than 1 products and if anyone of the product has ONG__C is checked then it should give me 1 row only of "Yes". And if there are no proucts with ONG__C as checked then it should give me 1 row of "No"
pconpcon
Then what you are trying to do cannot be done without a controller and more logic inside.  You will want to iterate through each OpportunityLineItem in your controller and generate your Boolean and use that Boolean on your visualforce page.
This was selected as the best answer