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
SFDummySFDummy 

Dependent pick list - contact or user

I am developing custom event organization implementation.  I have a requirement to have ability to pick either user or contact
organizer type - Internal (User) contractor(Contact) Other
(1)  can I present user with pick list When Internal selected 
Then a look up will be user User lookup
(2) When Picklist selection is Contractor 
then user will have contact Lookup

I can write custom code, any suggestions?
 
SonamSonam (Salesforce Developers) 
if you are talking about dependent picklists - this relationship is created between two picklists so we cannot really control a lookup through this relation.so I understand you wish to have the  Picklist as the controlling field and dependent field as a lokup right?
SFDummySFDummy
Yes, I want to see if I can have picklist as controlling field.

How can I show only Contact lookup or user lookup  but not both
SonamSonam (Salesforce Developers) 
The below code will give you the dependency you are looking for in the picklist and Lookup.
I've chosen this dependency on the case Object where a picklist value determines what Lookup the user will see - User/Contact:


<apex:page standardController="Case">
<apex:form >
<apex:pageBlock id="Dependentfields">

<apex:pageBlockSection >
                    
<apex:actionRegion >               

  <apex:inputField id="Picklist" value="{!case.Connect_With__c}" required="true" >

     <apex:actionSupport event="onchange" rerender="Dependentfields" />
  </apex:inputField>

</apex:actionRegion>
                 
</apex:pageBlockSection>

               
<apex:pageBlockSection id="lookup1" rendered="true">

 <apex:inputField id="user" value="{!case.User_connect__c}" rendered="{!IF(case.Connect_With__c ='User',true,false)}"/>

</apex:pageBlockSection>

<apex:pageBlockSection id="lookup2" rendered="true">

  <apex:inputField id="contact" value="{!case.ContactID}" rendered="{!IF(case.Connect_With__c ='Contact',true,false)}"/>  
                                                                     
</apex:pageBlockSection>

</apex:PageBlock>
</apex:form>
</apex:page>