+ Start a Discussion
Deepak Sharma 184Deepak Sharma 184 

In VF page - Put N/A when there is no record

Hi Expert,

I have a VF page in which there is a block 'Project Team', in this block we are displaying the record 'resourse full name',when there is no record there, table gets shrinked, hence i want to put N/A there when there is no record. but 'resource full name' is a formula field. How to put N/A there. 

VF Page - 

     <div class="main_container" style="margin-top:10px">
            <div class="animated flipInY col-lg-5 col-md-80 col-sm-80 col-xs-80">
                <div class="tile-stats">
                    <apex:outputLabel value="Deliverables/Objectives" style="color:#0A31FB;" />
                    <apex:panelGrid columns="1" border="0" style="border:hidden">

                        <!--apex:outputLabel value="Project:" style="border-hidden" />-->
                        <apex:outputText value="{!CloudbyzITPM__Project__c.CloudbyzITPM__Project_Goal__c}"
                            style="border-hidden"/>
                    
                    <!--apex:panelGrid columns="1" columnClasses="col1,col2" border="1" style="border:solid"
                        cellpadding="3">-->
                        <!--apex:outputLabel value="Description:" style="text-align:left;border-hidden" />-->
                        <apex:outputText value="{!CloudbyzITPM__Project__c.CloudbyzITPM__Description__c}"
                            style="white-space:pre-wrap;border-hidden"/>
                    </apex:panelGrid>
                </div>
            </div>
        </div>

Controller:- 
    
   
 List< CloudbyzITPM__Team_Member__c> tempTMlist =[select Id,CloudbyzITPM__Resource_Full_Name__c from CloudbyzITPM__Team_Member__c where CloudbyzITPM__Project__r.Id =: recordId];
    
     public List<CloudbyzITPM__Team_Member__c> gettempTMlist()
     
     {
     if(tempTMlist.size() < 3 ){
     for(integer i = 0; i <= (3 - tempTMlist.size());){
         
          tempTMlist.add(new CloudbyzITPM__Team_Member__c(CloudbyzITPM__Resource_Full_Name__c = null));
     }
     }    
         return tempTMlist;
    }








 
RD@SFRD@SF
Hi Deepak,

Use the following formula in the value of the resource full name 
"{!IF(ISNULL(temp),'N/A',<the formula value>)}"

Where temp is the tempTMlist list

Hope it helps
RD
Deepak Sharma 184Deepak Sharma 184
Hi RD@SF,

Thanks for ur help

I have included in vf page as - Its giving me compling error

 <div class="main_container" style="margin-top:10px">
            <div class="animated flipInY col-lg-2 col-md-2 col-sm-6 col-xs-12">
                <div class="tile-stats" >
                    <div class ="input-disabled" var = "pm" rendered = "true">
                    <div style="text-align:center">
                        <apex:outputLabel value="Project Team" style="color:#0A31FB;" />
                    </div>
                    <apex:pageBlock >
                        <apex:pageBlockTable value="{!IF(ISNULL(tempTMlist),'N/A',<CloudbyzITPM__Resource_Full_Name__c>)}" var="m" rows="3" rendered="{!tempTMlist.size>0}">
                            <apex:column >
                              <a href= "/{!m.id}" >
                                <!--<apex:param name="RId" value="{!m.Id}" />
                                <apex:outputLink value="{!URLFOR($Action.CloudbyzITPM__Team_Member__c.View, m.id)}" style="white-space:pre-wrap;border-hidden">-->{!m.CloudbyzITPM__Resource_Full_Name__c}</a>
                                <!--</apex:outputLink>-->
                           </apex:column>
                       </apex:pageBlockTable>
                    </apex:pageBlock>
                    <apex:commandButton styleClass="div5" value="more" action="{!redirecttoprjtm}"/>
                </div>
            </div>
        </div>
        </div>

But what is the formula value here?
 
Deepak Sharma 184Deepak Sharma 184
HI RD@SF,

Thanks for ur help

I have included in vf page as - Its giving me compling error

 <div class="main_container" style="margin-top:10px">
            <div class="animated flipInY col-lg-2 col-md-2 col-sm-6 col-xs-12">
                <div class="tile-stats" >
                    <div class ="input-disabled" var = "pm" rendered = "true">
                    <div style="text-align:center">
                        <apex:outputLabel value="Project Team" style="color:#0A31FB;" />
                    </div>
                    <apex:pageBlock >
                        <apex:pageBlockTable value="{!IF(ISNULL(tempTMlist),'N/A',<CloudbyzITPM__Resource_Full_Name__c>)}" var="m" rows="3" rendered="{!tempTMlist.size>0}">
                            <apex:column >
                              <a href= "/{!m.id}" >
                                <!--<apex:param name="RId" value="{!m.Id}" />
                                <apex:outputLink value="{!URLFOR($Action.CloudbyzITPM__Team_Member__c.View, m.id)}" style="white-space:pre-wrap;border-hidden">-->{!m.CloudbyzITPM__Resource_Full_Name__c}</a>
                                <!--</apex:outputLink>-->
  </apex:column>
                       </apex:pageBlockTable>
                    </apex:pageBlock>
                    <apex:commandButton styleClass="div5" value="more" action="{!redirecttoprjtm}"/>
                </div>
            </div>
        </div>
        </div>

But what is the formula value here?
 
RD@SFRD@SF
Hi 

Because the rendered value on the pageblock tables is not getting satisfied the value is coming as empty.
So add a outputPanel with rendered property to check if the list returned is null.
 
<div class="main_container" style="margin-top:10px">
            <div class="animated flipInY col-lg-2 col-md-2 col-sm-6 col-xs-12">
                <div class="tile-stats" >
                    <div class ="input-disabled" var = "pm" rendered = "true">
                    <div style="text-align:center">
                        <apex:outputLabel value="Project Team" style="color:#0A31FB;" />
                    </div>
                    <apex:pageBlock >
					<apex:OutputPanel rendered="{!IF(ISNULL(tempTMlist)">N/A</apex:Outputpanel>
                        <apex:pageBlockTable  var="m" rows="3" rendered="{!tempTMlist.size>0}">
                            <apex:column >
                              <a href= "/{!m.id}" >
                                <!--<apex:param name="RId" value="{!m.Id}" />
                                <apex:outputLink value="{!URLFOR($Action.CloudbyzITPM__Team_Member__c.View, m.id)}" style="white-space:pre-wrap;border-hidden">-->{!m.CloudbyzITPM__Resource_Full_Name__c}</a>
                                <!--</apex:outputLink>-->
							</apex:column>
                       </apex:pageBlockTable>
                    </apex:pageBlock>
                    <apex:commandButton styleClass="div5" value="more" action="{!redirecttoprjtm}"/>
                </div>
            </div>
        </div>
        </div>

This should do the trick

Regards
RD
Deepak Sharma 184Deepak Sharma 184
HI RD,

When iam saving this its giving me an error -    must be terminated by the matching end-tag </apex: outputpanel>

why is this error coming upon saving the class.

<div class="main_container" style="margin-top:10px">
            <div class="animated flipInY col-lg-2 col-md-2 col-sm-6 col-xs-12">
                <div class="tile-stats" >
                    <div class ="input-disabled" var = "pm" rendered = "true">
                    <div style="text-align:center">
                        <apex:outputLabel value="Project Team" style="color:#0A31FB;"/>
                    </div>
                    <apex:pageBlock>
                        <apex:outputPanel rendered ="{!IF(ISNULL(tempTMlist)"> N/A </apex:outputpanel>
                        <apex:pageBlockTable var="m" rows="3" rendered="{!tempTMlist.size>0}">
                            <apex:column>
                              <a href= "/{!m.id}" >
                                <!--<apex:param name="RId" value="{!m.Id}" />
                                <apex:outputLink value="{!URLFOR($Action.CloudbyzITPM__Team_Member__c.View, m.id)}" style="white-space:pre-wrap;border-hidden">-->{!m.CloudbyzITPM__Resource_Full_Name__c}</a>
                                <!--</apex:outputLink>-->
                           </apex:column>
                       </apex:pageBlockTable>
                    </apex:pageBlock>
                    <apex:commandButton styleClass="div5" value="more" action="{!redirecttoprjtm}"/>
                </div>
            </div>
        </div>
        </div>

Thanks & Regards,

Deepak

 
RD@SFRD@SF
I just edited the code in editor

try this it works for me
 
​<div class="main_container" style="margin-top:10px">
            <div class="animated flipInY col-lg-2 col-md-2 col-sm-6 col-xs-12">
                <div class="tile-stats" >
                    <div class ="input-disabled" var = "pm" rendered = "true">
                    <div style="text-align:center">
                        <apex:outputLabel value="Project Team" style="color:#0A31FB;" />
                    </div>
                    <apex:pageBlock >
                    <apex:outputPanel rendered="{!ISNULL(tempTMlist)}">N/A</apex:outputPanel>
                        <apex:pageBlockTable value="{!tempTMlist}" var="m" rows="3" rendered="{!tempTMlist.size>0}">
                            <apex:column >
                              <a href= "/{!m.id}" >
                                <!--<apex:param name="RId" value="{!m.Id}" />
                                <apex:outputLink value="{!URLFOR($Action.CloudbyzITPM__Team_Member__c.View, m.id)}" style="white-space:pre-wrap;border-hidden">-->{!m.CloudbyzITPM__Resource_Full_Name__c}</a>
                                <!--</apex:outputLink>-->
                            </apex:column>
                       </apex:pageBlockTable>
                    </apex:pageBlock>
                    <apex:commandButton styleClass="div5" value="more" action="{!redirecttoprjtm}"/>
                </div>
            </div>
        </div>
        </div>

Regards
RD
Deepak Sharma 184Deepak Sharma 184
HI RD,

It saved but did not work.

Regards,

Deepak
RD@SFRD@SF
Hmm,
What does it show ?
screen shot??

RD
Deepak Sharma 184Deepak Sharma 184
User-added image

see the 'project team' section when there is no records, it is shrinking. I want to put like others displaying

Thanks & Regards,

Deepak
RD@SFRD@SF
Try updating the rendered condition in N/A output panel as
 
<apex:outputPanel rendered="{!tempTMlist.size<=0}">N/A</apex:outputPanel>

and can you also inspect the page and update me the screen shot there