+ Start a Discussion
apex code shareapex code share 

How to get the lookup field dependent to another look-up field.

I have a look field having some vales and i want when i select any value in this look up then the values related to that look up should reflect in another look -up field values .......its something like controlling and dependent scenario....please help me in acheiving this.

Best Answer chosen by Admin (Salesforce Developers) 
Devendra@SFDCDevendra@SFDC

 

Try this:

 

To define a lookup filter:

  1. You can create lookup filters for new relationship fields in step 3 of the custom field wizard. To create a lookup filter on an existing field:
    1. Navigate to the fields area of the object that contains the relationship field:
      • For standard objects, click Your Name | Setup | Customize, select the appropriate object from the Customize menu, and click Fields.
      • For custom objects, click Your Name | Setup | Create | Objects, and select one of the custom objects in the list.
    2. Click Edit next to the name of the lookup or master-detail relationship field to which you want to apply the filter.
  2. In the Lookup Filter Options section, click Show Filter Settings.
  3. Specify the filter criteria a record must meet to be a valid value. To specify criteria, click Insert Suggested Criteria and choose from a list of suggested criteria, or manually enter your own criteria. To enter your own criteria:
    1. In the first column, click the lookup icon or start typing in the text box and select a field.
    2. In the second column, select an operator.
    3. In the third column, select Value if Salesforce should compare the field in the first column with a static value, or select Field if Salesforce should compare the field in the first column with the value of another field.
    4. In the fourth column, enter the value or select the field that Salesforce should compare with the field in the first column.
    Note
    • Click Add Filter Logic to add Boolean conditions.
    • You can select from fields on the current record, the lookup object, or the user record. You can also choose related fields that are one relationship away from the lookup object. Salesforce assists you by listing the available fields and relationships when you click the lookup icon or click inside the text boxes.
    • Lookup filter criteria can compare fields of different types as long as they are compatible.
  4. Specify whether the filter is required or optional. For fields with optional lookup filters, only values that match the lookup filter criteria appear in the lookup dialog initially; however, users can click the Show all results link in the lookup dialog to remove the filter and view all search result values for the lookup field. Also, optional lookup filters allow users to save values that don't match the lookup filter criteria, and Salesforce does not display an error message if a user tries to save such values.

    For required lookup filters, specify whether you want Salesforce to display the standard error message or a custom message when a user enters an invalid value.

  5. Optionally, enter text to display in the lookup search dialog. Consider text that guides users in their searches and explains the business rule that the lookup filter implements.
  6. Leave Active selected.
  7. Click Save.

Hope this helps.

 

Thanks,

Devendra S

 

All Answers

Devendra@SFDCDevendra@SFDC

 

Try this:

 

To define a lookup filter:

  1. You can create lookup filters for new relationship fields in step 3 of the custom field wizard. To create a lookup filter on an existing field:
    1. Navigate to the fields area of the object that contains the relationship field:
      • For standard objects, click Your Name | Setup | Customize, select the appropriate object from the Customize menu, and click Fields.
      • For custom objects, click Your Name | Setup | Create | Objects, and select one of the custom objects in the list.
    2. Click Edit next to the name of the lookup or master-detail relationship field to which you want to apply the filter.
  2. In the Lookup Filter Options section, click Show Filter Settings.
  3. Specify the filter criteria a record must meet to be a valid value. To specify criteria, click Insert Suggested Criteria and choose from a list of suggested criteria, or manually enter your own criteria. To enter your own criteria:
    1. In the first column, click the lookup icon or start typing in the text box and select a field.
    2. In the second column, select an operator.
    3. In the third column, select Value if Salesforce should compare the field in the first column with a static value, or select Field if Salesforce should compare the field in the first column with the value of another field.
    4. In the fourth column, enter the value or select the field that Salesforce should compare with the field in the first column.
    Note
    • Click Add Filter Logic to add Boolean conditions.
    • You can select from fields on the current record, the lookup object, or the user record. You can also choose related fields that are one relationship away from the lookup object. Salesforce assists you by listing the available fields and relationships when you click the lookup icon or click inside the text boxes.
    • Lookup filter criteria can compare fields of different types as long as they are compatible.
  4. Specify whether the filter is required or optional. For fields with optional lookup filters, only values that match the lookup filter criteria appear in the lookup dialog initially; however, users can click the Show all results link in the lookup dialog to remove the filter and view all search result values for the lookup field. Also, optional lookup filters allow users to save values that don't match the lookup filter criteria, and Salesforce does not display an error message if a user tries to save such values.

    For required lookup filters, specify whether you want Salesforce to display the standard error message or a custom message when a user enters an invalid value.

  5. Optionally, enter text to display in the lookup search dialog. Consider text that guides users in their searches and explains the business rule that the lookup filter implements.
  6. Leave Active selected.
  7. Click Save.

Hope this helps.

 

Thanks,

Devendra S

 

This was selected as the best answer
Simangaliso Mathenjwa 6Simangaliso Mathenjwa 6
Does anyone know how to do this in Visualforce?