I have created a Vf page from which i need to fetch the value of new owner and need to save the value in property defined in controller:
Following is my vf page code:
<apex:pageBlockSection>
<apex:InputField label="user" value="{!a.ownerid}"/>
</apex:pageBlockSection>
here a is object of opportunity
Controller code:
used one property to store the value:
public string ownername {get;set;}
Note: user will input the value through lookup field.
Any suggestions on this?
Best Answer
When you submit the page, Visualforce will update the
OwnerId
field of your opportunity objecta
automatically for you. If you want to use that value elsewhere (e.g. in a save method), you can just reference the value directly:and you can query for the corresponding name (if you need that):