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
xpatxpat 

rendered issue

Hello and Happy new year

 

I have an issue with rendered when the query in the controller return null, the record does not exist.

 

Below the code in the controller;

 

 

/*load data from Previous year account plan*/ Public Yearly_account_plan__c getR2009(){ for (Yearly_account_plan__c rqs1 : [select id ,year__c, account__c,contact__c, Aesthetic_patients_treated__c, name, Open_days__c, Q4_Volume_plan__c, Q3_Volume_plan__c ,Q2_Volume_plan__c, Q1_Volume_plan__c from Yearly_Account_Plan__c where start_date__c = last_year and Account__c = :System.currentPageReference().getParameters().get('id')]){ return rqs1; } return null; }

 

 

when I have a 2009 account plan all is fine but when I don't have a previous year account plan the first rendered in my page is not ok. I tried is null but same issue.

 

If you could help me with this, it will be fine

 

Thanks

 

Pat

 

Below the code of my page

 

<apex:pageBlockSectionItem > <apex:outputLabel value="Aesthetic patients treated" rendered="{!CONTAINS('GP',account.type)&& R2009.Aesthetic_patients_treated__c == 0}"/> <apex:outputfield value="{!req.Aesthetic_patients_treated__c}" rendered="{!CONTAINS('GP',account.type)&& R2009.Aesthetic_patients_treated__c == 0}"/> </apex:pageblocksectionItem> <apex:pageBlockSectionItem > <apex:outputLabel value="Aesthetic patients treated" rendered="{!CONTAINS('GP',account.type)&& R2009.Aesthetic_patients_treated__c <> 0}"/> <apex:outputfield value="{!R2009.Aesthetic_patients_treated__c}" rendered="{!CONTAINS('GP',account.type)&& R2009.Aesthetic_patients_treated__c <> 0}"/> </apex:pageblocksectionItem>

 

Best Answer chosen by Admin (Salesforce Developers) 
xpatxpat

I found out and now it works fine

 

<apex:pageBlockSectionItem > <apex:outputLabel value="Aesthetic patients treated" rendered="{!CONTAINS('GP',account.type)&& (isnull(R2009.Aesthetic_patients_treated__c )||R2009.Aesthetic_patients_treated__c == 0) }"/> <apex:outputfield value="{!req.Aesthetic_patients_treated__c}" rendered="{!CONTAINS('GP',account.type)&& (isnull(R2009.Aesthetic_patients_treated__c) ||R2009.Aesthetic_patients_treated__c == 0) }"/> </apex:pageblocksectionItem> <apex:pageBlockSectionItem > <apex:outputLabel value="Aesthetic patients treated" rendered="{!CONTAINS('GP',account.type)&& R2009.Aesthetic_patients_treated__c <> 0}"/> <apex:outputfield value="{!R2009.Aesthetic_patients_treated__c}" rendered="{!CONTAINS('GP',account.type)&& R2009.Aesthetic_patients_treated__c <> 0}"/> </apex:pageblocksectionItem>