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

Change record owner in VisualForce page

I'm using an outputfield to display the owner of my custom Project object in a VisualForce page - but I can't figure out how to add the [Change] link beside the owner name to enable the user to change the record owner.
<apex:outputfield value="{!Project__c.OwnerID}" />
Can anyone help? Thanks!
amar joshiamar joshi
as i understand from your post

if u want to change the record owner name u have to use

<apex:inputfield value="{!Project__c.OwnerID}"/>

<apex:outputfield> displays only read only properties

thanks & regards
Amar Joshi

Thanks for your reply. I guess I could use an input field, but I was really hoping I could replicate the way a record owner appears in a standard (non-VF) Salesforce page ... i.e. the owner name as a link to the user record, and a "[Change]" link beside the name. Is that not possible in VF?
amar joshiamar joshi

i was also stucked with this problem

i have find out a way like bellow

i have create on custom field "record owner" in my object in which i change the record owner the data type of that field is lookup
now i ma use <apex:inputfield value="{!gettermethodname.record_owner__C"}>
so i get same look and feel of original  now  to get the

in getter method u get the value of the owner and the assign it to record_owner_c now from look up button u can change the record owner
now at save time assign the record_owner__c to

with this way u can achieve the same look and feel of standard page and also change  the record owner

Thanks & Regards
Amar joshi
Lets Play CatchLets Play Catch
Create an html table and stick an html link to the change owner page in the same cell as the outputfield - like so:
<table border="0" cellpadding="0" cellspacing="0">
<tr><td align="left">
<apex: outputfield value="{!Custom_Object__c.OwnerID}"/>
<a href="{!Custom_Object__c.ID}/a?retURL=%2F{!Custom_Object__c.ID}">[Change]</a>

Message Edited by Lets Play Catch on 12-14-2008 04:17 PM

Message Edited by Lets Play Catch on 12-14-2008 04:18 PM
amar joshiamar joshi
yes my dear

but what happen in this stage

we can change the  but when we click the save button of that page it navigate me to the page like{!}

not my costume lead convert page or the standard lead convert page in lead object when we press convert button

what i want here i can change the and also want to navigate back my lead convert page

if this can be done without creating the costume lookup field record owner to the user object then please let me know

Thanks & regards
Amar Joshi
salesforce CRM consultant

try this


<a href="/{!id}/a?retURL=/{!id}">[Change]</a>








 Thank you!

Jack PondJack Pond
Emulate standard edits (Detail and Edit) for Case Owner and Contact.

I don't know if this is helpful, but certain object types have their own custom change functionality.  In this instance using Case/Contact, the Case Owner.  

This is in full context of a custom page, but you probably are most interested in the "apex:outputText".tag sets
<apex:page standardController="Case">
    <apex:pageBlock title="Hello {!$User.FirstName}!" mode="maindetail" >
        <apex:form >
            <apex:pageBlockSection title="Greeting" columns="1">
                You are viewing the detail pages for: {!case.CaseNumber}.
            <apex:pageBlockSection title="Case Information" columns="2" rendered="True" Id="CaseInfo" >
                    <apex:outputText label="Case Number" escape="False" value="{!case.CaseNumber} [{!LINKTO('View Hierarchy' , '/500?rlid=RelatedChildCaseList&hierarchy=1&fromroot=1',null, ['id'=case.Id]) }]" />
                    <apex:outputText label="Case Owner" escape="False" value="{!case.Owner.Name} [{!LINKTO('Change' ,'/' + LEFT(,15) + '/a?retURL=' + URLFOR('/apex/' + $CurrentPage.Name, null, ['id']), case.Id) }]" />
                    <apex:inputField value="{!case.ContactId}" />
    <apex:detail inlineEdit="true"/>
Screen Shot comparing customization and standard configuration