1

I have a visual force page, on my custom object Visit_Plan__c, looked like this

enter image description here

And my custom object relation : (Parent -> Child) Master_Visit_Plan__c -> Master_Visit_Plan_Branch__c -> Visit_Plan_Header__c -> Visit_Plan

I want to make billing account inputfield disappear if the Master_Visit_Plan__c Entitas_New_Field__c = 'Pusat'.

enter image description here

I tried to use IF inside the rendered

<apex:column headerValue="Billing Account">
               <apex:inputfield value="{!var.vp2.Billing_Account__c}" rendered="{!IF(var.vp2.Visit_Plan_Header__r.Master_Visit_Plan_Branch__r.Master_Visit_Plan__r.Entitas_New__c='Pusat',false,true)}"/>
               </apex:column>

But seems like the if condition didnt met.. because even if my Master_Visit_Plan__c entitas_new__c field != 'pusat' (Else), the billing account inputfield disappear too

2 Answers 2

1

You don't need to use an IF statement here, because = in an expression already returns a Boolean value:

rendered="{!var.vp2.Visit_Plan_Header__r.Master_Visit_Plan_Branch__r.Master_Visit_Plan__r.Entitas_New__c='Pusat'}"

As Adrian stated, you always need to put the value_when_true value before the value_when_false value, but it's simply more efficient to use Boolean values directly, when possible.

Edit:

If you want to invert the value, you can just use not-equals instead:

rendered="{!var.vp2.Visit_Plan_Header__r.Master_Visit_Plan_Branch__r.Master_Visit_Plan__r.Entitas_New__c!='Pusat'}"
2
  • 1
    The OP wants to hide if the value = the string so false as the value_if_true should be correct for the rendered attribute right? So the = should be != I believe
    – Eric
    Commented Aug 9, 2018 at 5:01
  • @Eric Good point, I may have misread it. I added an edit to that effect.
    – sfdcfox
    Commented Aug 9, 2018 at 6:41
0

This is simple condition and it's not mandatory to use if condition for this.

If you are still facing issue, check with value what you are receiving in page side.

Just put below debug log after Apex: column and check in inspect element -> Console tab.

console.log("debug"+{!var.vp2.Visit_Plan_Header__r.Master_Visit_Plan_Branch__r.Master_Visit_Plan__r.Entitas_New__c});

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .