We have a formula field that determines the correct From Email address on a Case based on a field on the related Contact and the Case Record Type. We've reached the character limit on the formula field after several rounds of optimization and it must be replaced.
My first instinct is to use Apex against Custom Metadata but this will require a trigger on both Case and Contact to ensure that a change to the source field on either record will result in the correct calculation. This seems inefficient.
Is it more efficient to do it with a Visualforce page to replace all the Layouts? Can you combine the use of Apex:detail with a controller to calculate the email so that maintenance of the pages can still be done from a standard Layout? What do you lose control of when you switch to using apex:detail?
We use the Quick Action Send Email for outbound messages from Cases and predefine the From Email field value based on a Formula Field currently.
A psuedocode example of the currently Formula is:
IF( RecordType.Name = "Career Services Case" ), CASE( Contact.Specialization__c , "abc-def","careerservices@someuniqueURL.com", "ghi-jkl","careerservices@someotheruniqueURL.net", etc.
There are 5 Record Types and over 60 specializations currently and we need it to scale to 100s of specializations, so we know that ultimately Formula Fields will not work.
Because the Send Email Quick Action automatically populates predefined field values on page load, there is no way (as far as I know) to trigger a check whether the parent Contact field (Specialization__c) has changed. Formula fields have the advantage that they do update on page load so they have worked well.