Filter by related records only when attaching a record

Posted by ByronB on 10-Nov-2014 11:28

Hi, we have a scenario where we have Account 1:M Contact and Account 1:M Opportunity and Contact M:1 Opportunity. If we crate an Opportunity (Based on a specific Account) and want to assign Contacts to that Opportunity we need to filter by the contacts that are only available for the Account being used for that Opportunity. Currently the Attach Contact shows all contacts across all Accounts. How can we filter only the related records?

All Replies

Posted by Gian Torralba on 10-Nov-2014 15:49

Hello,

You can use the rbf_setLookupFilter() method. Here is also a sample script on how you can apply the setLookupFilter method on your code:

<script>

/*run this function on click event of the account lookup field*/

function setContactFilter(){

  var accountId = rbf_getFieldValue("RXXXX") /*integration name of the account lookup field*/

  rbf_setLookupFilter("RXXXX_contact_relationship_name", "RXXX_name_of_account_relationship_on_contact_object", parseInt(accountId));

}

</script>

Hope this helps.

Thank you,

Gian

Posted by ymaisonn on 11-Nov-2014 07:45

Another possibility is to create a LinkLookup

On the Opportunity object properties page, "edit" the "contact" lookup:

Edit the Lookup properties as follows:

When you create or edit the Opportunities records, the list of contacts is displayed depending on the Account record chosen:

 


 

HTH

This thread is closed