0

In my visual-force page i have few div elements clubbed in one division. I want to control visibility of each of these sub-divisions using if condition. i.e. IF value of {!mapOfPaymentRecord['StudentDetails'].nm_Lead__r.Program_Preference_1__c} is not Null then show first sub div. IF value of {!mapOfPaymentRecord['StudentDetails'].nm_Lead__r.Program_Preference_2__c} is not Null then show Second sub div.....and so on.

My page

<div style="width:100%;overflow:hidden;">
    <div style="margin-bottom:2%;Float:left;width:50%"><b>Program Preference 1:</b>&nbsp;&nbsp;{!mapOfPaymentRecord['StudentDetails'].nm_Lead__r.Program_Preference_1__c}</div>
        <div style="margin-bottom:2%;Float:left;width:50%"><b>Program Preference 2:</b>&nbsp;&nbsp;{!mapOfPaymentRecord['StudentDetails'].nm_Lead__r.Program_Preference_2__c}</div>                   
        <div style="margin-bottom:2%;Float:left;width:50%"><b>Program Preference 3:</b>&nbsp;&nbsp;{!mapOfPaymentRecord['StudentDetails'].nm_Lead__r.Program_Preference_3__c}</div>
        <div style="margin-bottom:2%;Float:left;width:50%"><b>Program Preference 4:</b>&nbsp;&nbsp;{!mapOfPaymentRecord['StudentDetails'].nm_Lead__r.Program_Preference_4__c}</div>
        <div style="margin-bottom:2%;Float:left;width:50%"><b>Program Preference 5:</b>&nbsp;&nbsp;{!mapOfPaymentRecord['StudentDetails'].nm_Lead__r.Program_Preference_5__c}</div>
        <div style="margin-bottom:2%;Float:left;width:50%"><b>Program Preference 6:</b>&nbsp;&nbsp;{!mapOfPaymentRecord['StudentDetails'].nm_Lead__r.Program_Preference_6__c}</div>
        <div style="margin-bottom:2%;Float:left;width:50%"><b>Program Preference 7:</b>&nbsp;&nbsp;{!mapOfPaymentRecord['StudentDetails'].nm_Lead__r.Program_Preference_7__c}</div>
</div>

I have tried to add if condition in style attribute of Div element as suggested at this forum : http://sfdcsrini.blogspot.com/2014/06/how-to-check-if-condition-in-salesforce.html

<div style="width:100%;overflow:hidden;">
                <div style="margin-bottom:2%;Float:left;width:50%;{!IF(({!mapOfPaymentRecord['StudentDetails'].nm_Lead__r.Program_Preference_1__c}!=null),'','display:none')}"><b>Program Preference 1:</b>&nbsp;&nbsp;{!mapOfPaymentRecord['StudentDetails'].nm_Lead__r.Program_Preference_1__c}</div>
                <div style="margin-bottom:2%;Float:left;width:50%"><b>Program Preference 2:</b>&nbsp;&nbsp;{!mapOfPaymentRecord['StudentDetails'].nm_Lead__r.Program_Preference_2__c}</div>                   
                <div style="margin-bottom:2%;Float:left;width:50%"><b>Program Preference 3:</b>&nbsp;&nbsp;{!mapOfPaymentRecord['StudentDetails'].nm_Lead__r.Program_Preference_3__c}</div>
                <div style="margin-bottom:2%;Float:left;width:50%"><b>Program Preference 4:</b>&nbsp;&nbsp;{!mapOfPaymentRecord['StudentDetails'].nm_Lead__r.Program_Preference_4__c}</div>
                <div style="margin-bottom:2%;Float:left;width:50%"><b>Program Preference 5:</b>&nbsp;&nbsp;{!mapOfPaymentRecord['StudentDetails'].nm_Lead__r.Program_Preference_5__c}</div>
                <div style="margin-bottom:2%;Float:left;width:50%"><b>Program Preference 6:</b>&nbsp;&nbsp;{!mapOfPaymentRecord['StudentDetails'].nm_Lead__r.Program_Preference_6__c}</div>
                <div style="margin-bottom:2%;Float:left;width:50%"><b>Program Preference 7:</b>&nbsp;&nbsp;{!mapOfPaymentRecord['StudentDetails'].nm_Lead__r.Program_Preference_7__c}</div>
            </div>

But no luck...it says syntax error.

2

You don't use the merge syntax again once you are already in a merge.

Incorrect

{!IF({!condition}, truthy_value, falsy_value}

Correct

{!IF(condition, truthy_value, falsy_value)}

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.