0

I want to set one lookup for 2 filed objects (Contract & Opportunity). If it is not possible, can it be possible to to Select the field based on Picklist Value.

Eg: Picklist name (Pick and containing 2 values 1) Contract 2) Opportunity) If user will select CONTRACT from PICK, the Contract lookup field will enable & if user select OPPORTUNITY from PICK, the opportunity lookup field will enable and CONTRACT lookup field will disable, so based on that lookup will work for 1 field at a time.

1
  • You will need to use the second approach (one lookup to Contact and one to Opportunity, controlled by a picklist) as it is not possible to create a standard lookup which links to two different objects.
    – Doug B
    Commented Sep 22, 2015 at 9:28

1 Answer 1

0

Second option will work for you -

IF YOU ARE WORKING ON Visualforce Page - This will be much easier for you to do -

Visualforce page Code :

Where "MyObject__c" --- is object which has your picklist field and lookup fields into it MyPicklist__c ------ is your picklist which contains "Contract,Opportunity" values in it.

<apex:page standardController="MyObject__c">
<apex:form >
  <apex:inputField value="{!MyObject__c.Contract__c}" rendered="{!if(MyObject__c.MyPicklist__c=='Contract',true,false)}"/>
    <apex:inputField value="{!MyObject__c.Opportunity__c}" rendered="{!if(MyObject__c.MyPicklist__c=='Opportunity',true,false)}"/>  
</apex:form>
</apex:page>

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .