0

WANT TO DISPLAY MY OWNER FIELD ON VISUAL FORCE FIELD.

Example:

I HAVE Account (Standard Object) OWNER IS Umadevi I'm unable to display my woner field on the visual force page

<apex:inputField value=" {!Account__c.owner} "/>
 OR
<apex:outputField value="{!Account__c.Owner}"/>

My Vf page code

<apex:page standardcontroller="Account" tabstyle="Account">

 <apex:form >

 <apex:sectionheader title="Account Edit" subtitle="{!if(Account.Id==null,'New Account',Account.Name)}"></apex:sectionheader>
<apex:pageblock mode="edit" id="leadPB" title="Account Edit">

 <apex:pageblockbuttons >
 <apex:commandbutton action="{!save}" value="Save"></apex:commandbutton>
 <!-- If you wish to implement Save & New functionality you will have to write an Apex Extension with your own Save & New Method -->
 <apex:commandbutton action="{!cancel}" value="Cancel"></apex:commandbutton>
 </apex:pageblockbuttons>

        <apex:pageBlockSection >

        <apex:inputtext value="{!Account.FirstName}" />
         <apex:inputtext value="{!Account.LastName}" />

                       <apex:inputField value="{!Account.Stage__c}"/>
            <apex:inputField value="{!Account.Status__c}"/>
            <apex:inputtext value="{!Account.PersonMobilePhone}"/>
            <apex:inputtext value="{!Account.CustomLandLine__c}"/>
            <apex:inputField value="{!Account.City__c}"/>
            <apex:inputField value="{!Account.PersonEmail}"/>
             <apex:inputField value="{!Account.Source__c}"/>
            <!-- <apex:commandButton action="{!save}" value="Save!"/>-->
        </apex:pageBlockSection>
    </apex:pageBlock>
<apex:pageMessages />
</apex:form>
</apex:page>

I need to set default name is umadevi

3
  • Use {!Account__c.OwnerId} which is the ID of the User and the value that needs to be edited.
    – Keith C
    Commented Apr 1, 2016 at 8:06
  • it shows the which user login,but i need the default value as umadevi
    – Sakthi S
    Commented Apr 1, 2016 at 8:10
  • i don't want show the field in page but after save the page show the customer name as umadevi(using backend)
    – Sakthi S
    Commented Apr 1, 2016 at 8:16

1 Answer 1

2

If you only want this defaulting to happen when the Visualforce page is used you can use a controller extension:

public with sharing class MyExtension {
    private ApexPages.StandardController sc;
    public MyExtension(ApexPages.StandardController sc) {
        this.sc = sc;
    }
    public PageReference save() {
        Account a = (Account) sc.getRecord();
        a.OwnerId = [select Id from User where Name = 'umadevi'].Id;
        return sc.save();
    }
}

that is hooked in like this:

<apex:page standardcontroller="Account" tabstyle="Account" extensions="MyExtension">
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .