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
Patricia LimPatricia Lim 

How to <apex:inputField> with a master-detail relationship?

Hi all. I am creating an <apex:form> with one of the fields being a master-detail relationship that looks up the parent in the UI field. When I add this to my form, it does not appear on the VF page - what am I missing here?

User-added imageCode:
<apex:page standardController="Scholarship_Award__c">
    <h1>2020-2021 Academic Year</h1>
    <apex:form >
    <!-- Hi -->
    <apex:pageBlock title="Add Scholarship Awards">
        <apex:pageBlockSection columns="2">
            <apex:inputField value="{!Scholarship_Award__c.Name}"/>
            <apex:inputField value="{!Scholarship_Award__c.Year__c}"/>
        </apex:pageBlockSection>
        <apex:pageBlockButtons >
            <apex:commandButton action="{!save}" value="Save"/>
        </apex:pageBlockButtons>
    </apex:pageBlock>
    </apex:form>
</apex:page>

 
AnudeepAnudeep (Salesforce Developers) 

Do you see any difference in the FLS set for these two fields in this Object?
Patricia LimPatricia Lim
No. I am the system admin and the objects are visible to me on the UI 
Patricia LimPatricia Lim
Edit: I noticed that lookup relationships appear OK 
User-added image
AnudeepAnudeep (Salesforce Developers) 

Can you append a record Id that has a name field populated to the VF page and see if it displays any value? 

https://Salesforce_instance/apex/HelloWorld2?id=001D000000IRt53
AnudeepAnudeep (Salesforce Developers) 

Also, can you run the below query, please?
 
SELECT Id, Field, SObjectType, PermissionsRead, PermissionsEdit FROM fieldPermissions WHERE SObjectType = 'Scholarship_Award__c' AND parentId in ( SELECT id FROM permissionSet WHERE PermissionSet.Profile.Name = 'System Administrator')

 
Patricia LimPatricia Lim
Thanks. OK so when appending a record ID to the URL I do see the name appear in the Scholarship Name field... but I will need this field to be a lookup so that our users can enter a specific scholarship award depending on the record they are entering.

User-added image
Patricia LimPatricia Lim
Edit: Found out I will need a custom controller for user input into master-detail relationships - will make a separate post on this.Thanks