0

I have an output text field in visualforce page, which has a rendered condition. A few permission set does not have access to that object being checked in the rendered condition and we are getting this error:

The value 'null' is not valid for operator '>'. Error is in expression '{!cert.certiObj.Insured_Informations__r.size > 0}' in component in page dispositionpage`

Is there any work around to still render the page succecssfully to ignore the error?

<apex:outputText value="{!cert.certiObj.Insured_Informations__r[0].Insured_Info_Name__c}" rendered="{!cert.certiObj.Insured_Informations__r.size > 0}" id="prodName2"/>

How do I check if Cert.certiObj is null then don't check for null on child obj?

4

You can check if your collection is null before comparing its size. Note this error indicates cert.certiObj.Insured_Informations__r is null, not cert.certiObj.

<apex:outputText ...
    rendered="{!AND(cert.certiObj.Insured_Informations__r != null, cert.certiObj.Insured_Informations__r.size > 0)}" />

However, this approach is quite clunky, and it may be worth just caching the Boolean as a property:

public Boolean getHasInformation()
{
    return cert.certObj.Insured_Informations__r != null &&
        !cert.certObj.Insured_Informations__r.isEmpty();
}

Then in your markup simply:

<apex:outputText ...
    rendered="{!hasInformation}" />

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.