Skip to main content
5 of 5
deleted 4 characters in body

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

Controller :

public 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="{!IF(ServiceIns != null, true, false)}"> <!--Outputpanel rendered in "ServiceIns" not equal to null-->
    <apex:outputField value="{!ServiceIns.Terminal__c}" />
    <apex:outputField value="{!ServiceIns.Location__c}" />
    <apex:outputText value="{!ServiceIns.Account__r.Name}" />
    <apex:outputText value="{!ServiceIns.Opportunity__r.Works_CSP__c}" />
    <apex:outputField value="{!ServiceIns.Airports__c}" />
    <apex:outputText value="{!ServiceIns.Opportunity__r.Name}" />
    <apex:outputText value="{!ServiceIns.Service__r.name}" />
    <apex:outputField value="{!ServiceIns.Physical_ID__c}" />
</apex:outputPanel>