Skip to main content
1 of 5

This is simple way to display your List values in VF page. It may help to you.

Controller :

Service_Instance__c ServiceIns { get; set; } // getter setter initialize

public void gennumber2(){

    List<Service_Instance__c> serv = [SELECT Id, Name, Account__c, ... FROM Service_Instance__c WHERE USI__c =:usi1 limit 1]; // Query the values
    
    if(serv.size() > 0){  // Check whether list is empty or not
        ServiceIns = serv[0];  // Assign get set variable value
    } else {
        ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Warning, 'The USI number is invalid')); // else show the error message
    }
}

Page :

<apex:outputPanel rendered="ServiceIns != null"> <!--Outputpanel rendered in "ServiceIns" not equal to null-->
    <apex:outputField value="Building: {!ServiceIns.Terminal__c}" />
    <apex:outputField value="Room: {!ServiceIns.Location__c}" />
    <apex:outputField value="Account: {!ServiceIns.Account__r.Name}" />
    <apex:outputField value="Work Order Number: {!ServiceIns.Opportunity__r.Works_CSP__c}" />
    <apex:outputField value="Airport: {!ServiceIns.Airports__c}" />
    <apex:outputField value="Opportunity Name: {!ServiceIns.Opportunity__r.Name}" />
    <apex:outputField value="Local Service Name: {!ServiceIns.Service__r.name}" />
    <apex:outputField value="Physical ID: {!ServiceIns.Physical_ID__c}" />
</apex:outputPanel>