I have a visualforce page that is creating a record in Admin_Tracking__c. Their is a master detail field of Account on that object. For some reason the Account field won't show on my VF page. Anyone run into this issue before?

P.S. If I change the field to lookup instead of master detail the field displays as it should. I want to keep the field as master detail.

<apex:page Controller="Admin_Tracking_Controller" showHeader="false" sidebar="false">

    <apex:form style="background-color:#D8DDE7;height:350px" >
        <div class="h1">
            Admin Time Tracking
        <div class="b1">
            <apex:outputText >The Hub:</apex:outputText>
            <br/><apex:outputText value="{!bcs.Name}" />
            <br/><apex:outputText >Activity:</apex:outputText>
            <br/><apex:inputField value="{!adminTracking.Activity__c}"/>
            <br/><apex:outputText >Account:</apex:outputText>
            <br/><apex:inputField value="{!adminTracking.Account__c}"/>
            <br/><apex:outputText >Carrier:</apex:outputText>
            <br/><apex:inputField value="{!adminTracking.Carrier__c}"/>
            <br/><apex:outputText >Time Utilized:</apex:outputText>
            <br/><apex:inputField value="{!adminTracking.Time_Utilized__c}"/>
            <br/><apex:outputText >Notes:</apex:outputText>
            <br/><apex:inputField value="{!adminTracking.Tracking_Notes__c}" style="resize:none;height:50px;"/>

        <div class="b2" align="center" draggable="false" > 
            <apex:commandLink value="Save Time" action="{!save}" styleClass="btn" style="text-decoration:none;padding:4px;" />




public class Admin_Tracking_Controller {

    public Admin_Tracking__c adminTracking { get; set; }
    public BCS__c bcs {get; set;}

    public Admin_Tracking_Controller() {
        bcs = [Select Id,Name FROM BCS__c WHERE User__c = :UserInfo.getUserId() LIMIT 1];


    public PageReference save() {

        try {
            upsert adminTracking;
        } catch(DmlException e) {
            System.debug('The following exception has occurred: ' + e.getMessage());
        }catch(Exception e) {
            System.debug('An exception occurred: ' + e.getMessage());

        return null;


enter image description here

  • Change apex:inputField to apex:outputField for Account Nov 15 '16 at 21:06
  • Nope, that didn't work.
    – Matt M
    Nov 15 '16 at 21:08
  • 2
    Santanu Boral's comment gave me an idea. Try checking your Master-Detail field to see if Allow Re-Parenting is checked. If it isn't, try checking it. I've no idea if this will work, but if it does, I'll post an answer.
    – Derek F
    Nov 15 '16 at 21:13
  • Nope, field still doesn't show after setting reparenting property.
    – Matt M
    Nov 15 '16 at 21:20
  • Whoops, Derek F, you found it. I hadn't changed the field back to an inputField. Once I did, your change made it work.
    – Matt M
    Nov 15 '16 at 21:23

This particular issue is the result of 2 factors:

  1. You're trying to create an Admin_Tracking__c record (hence Account__c is blank)
  2. Your Account__c field is a master-detail relationship field

Why it isn't working

By default, Master-Detail fields do not allow anyone to change the value contained in the field after it has been set once. This effectively makes the field "read-only". If you check the Field-Level Security (FLS) setting for a Master-Detail field, you'll see that the "read only" checkboxes aren't checked, but you also can't set/unset this for any profile.

Because it's effectively a read-only field, Salesforce sees no point in rendering the lookup field input + icon.

If a Master-Detail field is populated, and you use the field in an <apex:inputField> tag, Salesforce will simply render the value of the field. In your case, since there is no value populated, this simply shows up as a blank field.

Making things work the way you want them to

You can change this by checking the Allow reparenting checkbox when you edit the field through the Salesforce web UI. Allowing reparenting changes the field to be editable.

You still can't do anything with the read-only checkbox if you try to edit FLS, so this effectively makes it read-write for everyone (you might be able to control this through some other mechanism, but I don't care to find out what that mechanism might be).

Since the field is now editable, Salesforce will render the input field box + lookup icon.


You don't have to set reparenting as true. The only thing you need to do is that initialize the variable as

adminTracking = new Admin_Tracking__c ();

in constructor. This will resolve your issue even without setting reparenting as true


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.