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
AsshAssh 

Master detail relationship on Visualforce

Hi,

 

I have created a custom object called Employment details. I have master detail relationship between Emplyment details object and contact object. I am developing a visualforce page to enter  employment details. In this page , I need to select contact from standard object contact to associate particular contact to employment details. How to acheive this in visualforce? I am a beginner in Visulaforce. If anybody has an idea about this please let me know. Your help is greatly appreciated

 

Thank you,

Assh.

Best Answer chosen by Admin (Salesforce Developers) 
bob_buzzardbob_buzzard

In this case you'd just use an InputField bound to the contact field on your employment details record.

 

For example, if your employment details object is Employment_Details__c and the contact field is Contact__c, then you'd use markup similar to the following:

 

 

<apex;inputField value="{!Employment_Details__c.Contact__c"/>

 This will generate you a lookup field to select a contact.

 

All Answers

bob_buzzardbob_buzzard

In this case you'd just use an InputField bound to the contact field on your employment details record.

 

For example, if your employment details object is Employment_Details__c and the contact field is Contact__c, then you'd use markup similar to the following:

 

 

<apex;inputField value="{!Employment_Details__c.Contact__c"/>

 This will generate you a lookup field to select a contact.

 

This was selected as the best answer
AsshAssh

Thank you for your response. I implemented that way and it worked. I have one problem here. When I enter contact name , it does not allow me to lookup contact list. Suppose the name is not in the contact , and, I try to save then it displays "Error: No matches found". How can I have lookup functionality on the Visualforce page so that I can select contact from the contact list?  It is working fine if I enter contact name which is already in the contact list.Please help me on this.

 

Thank you,

Assh

AsshAssh

Hi,

 

Actually, I had added some style sheet static resource and that caused the problem with the contact field. I removed the style sheet now. and I can search in the contact filed.

 

Thank you ,

Assh