How to enhance e2a Address Lookup to use a Specific Contact Lookup on Junction object?

 If the soft setting 'Override_Address_Lookup_Contact_Field 'is defined, then for that particular junction object, it will use the specified field to read contacts.  

 

Let us understand this using an example. Suppose you have a custom object 'Request Items' and that has multiple Contact lookups on it. And, 'Request Item' is also associated with (i.e. it is the junction object  for) Request object. Now, when you open e2a email client from a Request record, you want e2a to load contact of a specific lookup instead of choosing an aribitraty contact lookup, then you can do this via this soft setting.

 

1. Create a Custom Metadata Type

Let's create a Custom Metadata Type 'e2a Customer Settings'. If you have already created this in the past for some other soft setting for e2a then you can skip this step and move to Step 2.

  1. Go to 'Setup' and type 'Custom Metadata Type' in the quick find box .

  2. From the results, open 'Custom Metadata Type'.

  3. Press on 'New Custom Metadata Type' to create a new Custom Metadata Type. 

  4. Set the Label as: e2a Customer Settings 

  5. Set the Object Name as: e2a_Customer_Settings__mdt (note the "__mdt" gets added automatically) 

2. Create a Custom Field.

You have created a Custom Metadata type now. If you have already created it in the past then you can skip this step. Please follow the steps below to create a field under it:  

  1. In the same Custom Metadata Type record, look for the 'Custom fields' section and press on 'New' .

  2. Select Type: Text (255) 

  3. Enter Label as: Value 

  4. Enter API Name as: Value__c 

  5. Add in Help: Add the value in a name/value pair, using the Label field of the record for the name 

3. Create a Record under the Custom Metadata Type

Next, user will have to create one record under the newly created metadata type. Please follow the steps to create the required records: 

  1. Go to 'Setup' and type 'Custom Metadata Type' in the quick find box. 

  2. Open the 'Custom Metadata Types' from the result and look for the newly created metadata type i.e. e2a Customer Settings. 

  3. Press on 'Manage Records' - an option residing on the left side of the metadata type .

  4. Press on 'New' 

  5. Provide the below details: 

Name: Override_Address_Lookup_Contact_Field 

Label: (any) 

Value: [{"objectName":"ortsoo_e2a__Request_Item__c", "fieldName":"ortoo_e2a__Contact_2__c"}] 

 

objectName will refer to the junction object. 

fieldName will be the Contact lookup which we want to use to fetch contacts in address lookup. 

 

Now, when we open the e2a Email Client from a REQUEST record, it should show the contact records linked to Request Items specified using the field mentioned in above Value field. 

 

Can I customize the labels and field names?

Yes, you can customize the labels and field names to suit your needs, as long as the functionality remains intact.

Where can I manage this setting after it is created?

Once the setting is configured, you can manage it by navigating to Setup > Custom Metadata Types > e2a_Customer_Settings__mdt > Manage. Here, you can create, update, or delete records as needed.

Why use Custom Metadata Types for this setting?

Using Custom Metadata Types allows you to store and manage configuration settings at the application level. This approach provides flexibility and central control without requiring custom code, making it easier to maintain and update your settings across your Salesforce organization.

Is this approach recommended by Salesforce?

Yes, Salesforce recommends using Custom Metadata Types for settings like this. It provides a scalable and maintainable way to manage configurations within your Salesforce environment without modifying the underlying code.

 

Please contact us at support@ortooapps.com for any questions.

Was this information helpful?
Quick survey: How do you rate Email-to-anything?
★★★★★ - EXCELLENT
★★★★ - GOOD
★★★☆☆OK
★★☆☆☆POOR
☆☆☆☆ - RUBBISH

-