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
Sandesh D GanjareSandesh D Ganjare 

Can we display the master detail field?

 hi,
I have Employee Name field which having master ralationship with standard contact object. I want to display that Employee Name field automatically based on the name of logged in user name in visualforce page.  

help me...!
regards,
sandesh
Balaji BondarBalaji Bondar
Hi Sandesh,

You can use below code and map user field on VF on load of Page:
public class TestClass{
  public user currentuser{get;set;}
  public TestClass(ApexPages.StandardController cont){
     currentuser=new User();
     currentuser=[Select Id,Name,Email from User where Id=:userinfo.getuserId()];
  } 
}

Important :
If this is what you were looking for then please mark it as a "SOLUTION" or You can Click on the "Like" Button if this was beneficial for you.