0

For Case object there are two input fields Account and Contact.

I want the Contact inputField lookup to show only contact that belongs to Account inputField value chosen for this Case

Referring salesforce documentation https://help.salesforce.com/articleView?id=fields_lookup_filters_defining.htm&type=0, I have setup filter criteria for Contact as below

Contact: Account matches Case:Account from suggested criteria.

The Contact lookup works perfect only if I have Account as inputField on the page. I want to set the Case Account from controller and don't want to show it on UI layout and be able to see case Contact lookup filtered by Case Account.

I tried below code for Account input for Case

<apex:inputField rendered="false"/>
<apex:inputHidden/>

But dependent lookup filter for case contact based on case account doesn't work unless I use below for Account input for Case edit layout

<apex:inputField/>

Is this a bug in salesforce?

  • The consideration page @help.salesforce.com/… for dependent lookup says Versions 16.0 and higher of the Salesforce API support lookup filters. Lookup filters are enforced when you load data through the API. NOW I am working with 17.0 and this is still the issue. Am I, greenhorn in salesforce development, making any mistake in understanding concepts here? – veer7 Feb 27 '17 at 7:26
0

To work the dependent lookup properly both fields should be present in the page. One thing you can do, hide the Account lookup field by using style property display:none;. But as it is a lookup field there are a couple of other components present beside the input field. So wrap it inside a <apex:outputPanel and hide the panel instead as below.

<apex:page standardController="Case" extensions="TestCaseController" >
    <apex:form>
        <apex:outputPanel style="display:none;" >
            <apex:inputField value='{!myCase.AccountId}'/>
        </apex:outputPanel>
        <apex:inputField value='{!myCase.ContactId}'/>
    </apex:form>   
</apex:page>
  • This workaraound helps! Cheers!!!! Also please check my comments on original question. – veer7 Feb 27 '17 at 7:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.