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
NGhosNGhos 

Want to display a particular field of the record of a custom object

VF

<apex:page controller="addressfinderController" tabstyle="Location">

<apex:form >

<apex:pageBlock mode="edit">

<apex:pageMessages />

<apex:pageBlockSection >

 

<apex:inputField value="{!Location__c.Company__c}"/>

<apex:inputField value="{!Location__c.Location_Address__c}"/>

</apex:pageBlockSection>

<apex:pageBlockButtons location="bottom">

<apex:commandButton value="Save" action="{!save}"/>

</apex:pageBlockButtons>

</apex:pageBlock>

</apex:form>

</apex:page>

 

 

 

Controller

public class addressfinderController{

public Location__c location { get; private set; }

public addressfinderController() {

Id id = ApexPages.currentPage().getParameters().get('id');

location = (id == null) ? new Location__c() :

[SELECT Company__c,Location_Address__c FROM Location__c WHERE Id = :id];

}

public PageReference save() {

try {

upsert(location);

} catch(System.DMLException e) {

ApexPages.addMessages(e);

return null;

}

// After Save, navigate to the default view page:

return (new ApexPages.Controller(location)).view();

}

}