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
sameer123sameer123 

Master detail relationship lookup in VF page

Hi all,

 

I have custom VF page and a custom controller for it. I have one custom object which has custom field Account__c.

Account__c has master detail relationship with standard object "Account" . Using input field tag i want to show it on

VF page as a lookup field for accounts.

 

I am using

<apex:inputField id="account" value="{!acfContract.Account__c}"/>

 

I am not getting any error.

But on VF page only label account is displayed and not lookup tab.

 

Please help me.

Best Answer chosen by Admin (Salesforce Developers) 
SSRS2SSRS2

Sameer master lookup behavior is you can add new record but you cannot edit that record after add. That is the reason for hide the lookup icon.

 

See following description for master lookup field

Creates a special type of parent-child relationship between this object (the child, or "detail") and another object (the parent, or "master") where:

  • The relationship field is required on all detail records.
  • Once the value of the relationship field has been saved, it cannot be changed.
  • The ownership and sharing of a detail record are determined by the master record.
  • When a user deletes the master record, all detail records are deleted.
  • You can create rollup summary fields on the master record to summarize the detail records.

The relationship field allows users to click on a lookup icon to select a value from a popup list. The master object is the source of the values in the list.

 

-Suresh

All Answers

SSRS2SSRS2

Hello Sameer;

  Once the value of the relationship field has been saved, it cannot be changed.(see Master-Detail Relationship Description)

 

-Suresh

sameer123sameer123

Hi,

Thanks for reply.

What i want to do is, in my custom object contract i want to associate existing account with it.

So on my custom VF page form, where i accept values for custom object fields, i just want user to lookup accounts and select it for that particular contract object.

What should i do to get lookup icon for this feature???

Please help me.

Thank you.

SSRS2SSRS2

I think better to create Lookup Relationship not master detail relationship.

 

-Suresh

sameer123sameer123

Hi,

Yes i created lookup relationship and in that case its working fine.

But project manager said we need the relationship to be masterdetail.

So i am trying it.

When i try to create new record for my custom object using salesforces standard window to add new records then on

that page how it shows lookup icon? (even when my relation ship is master detail)

Also tell me what is meaning of your first reply.i didnt get it.

 

Thank you

SSRS2SSRS2

Sameer master lookup behavior is you can add new record but you cannot edit that record after add. That is the reason for hide the lookup icon.

 

See following description for master lookup field

Creates a special type of parent-child relationship between this object (the child, or "detail") and another object (the parent, or "master") where:

  • The relationship field is required on all detail records.
  • Once the value of the relationship field has been saved, it cannot be changed.
  • The ownership and sharing of a detail record are determined by the master record.
  • When a user deletes the master record, all detail records are deleted.
  • You can create rollup summary fields on the master record to summarize the detail records.

The relationship field allows users to click on a lookup icon to select a value from a popup list. The master object is the source of the values in the list.

 

-Suresh

This was selected as the best answer
sameer123sameer123

Hi,

 

Thank you very much for the help. :)