<td >
Fees: <apex:outputtext value="{! If(abInsurance !=null,'Rs. {!abInsurance.charges__c}',If(xyInsurance!=null,'Rs. {!xyInsurance.charges__c}','None')) }"/> 

Only one of the Insurance can have value at a time. 

I cannot check the VF page, but is the above code correct for retrieving the dynamic value for field 'charges_c'?


1 Answer 1


You cannot place expressions inside expressions. You would want to remove the extra bits.

Fees: <apex:outputtext value="{!If(abInsurance !=null,'Rs. ' & abInsurance.charges__c, If(xyInsurance!=null,'Rs. ' & xyInsurance.charges__c,'None')) }"/> 
  • I updated my code according to your suggestion but I got below error: Incorrect parameter type for operator '&'. Expected Text, received Number For time sake I am using below code, but currently digging more into '&' operator: Fees: Rs. <apex:outputtext value="{!If(abInsurance !=null, abInsurance.charges__c, If(xyInsurance!=null, xyInsurance.charges__c, '0')) }"/>
    – PiK
    Commented Aug 5, 2020 at 15:34
  • @PritishKumbhare I should have figured that was a number field. You could use TEXT() to convert it to a String, but I actually like your suggestion even better.
    – sfdcfox
    Commented Aug 5, 2020 at 15:37
  • Thanks, @sfdcfox for TEXT() and previous suggestion. Both of them were helpful.
    – PiK
    Commented Aug 5, 2020 at 15:42

You must log in to answer this question.

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