2

I am looking to reformat a formula field I've created for a custom object. This formula field, disambiguates between the account object and contact object, as we are on the one-to-one relationship model in Salesforce, in which a contact that is an individual is both contact/account and a contact representing a company is a group.

Currently my formula for the field is configured this way, I've created a concatenated formula in contact object which takes the first and last name and merges it into one. For instance First Name: Joe Last Name: Smith = Joe Smith

For the custom Object I've designed this formula in the field

IF(Account__r.Name =  Contact__r.FullName__c , NULL,"Attn: " & 
   Contact__r.FirstName & Contact__r.FullName__c)

However, at times, when I only input the last name and leave the first name field blank, in the instance that the contact does not have the first name, the Attention to formula returns a value when it should be blank.

Are there any customizations, I can make to my formula to make it so that even without the first name filled, it only returns when the account name and contact name do not match. IE Account Name SampleCO, Contact Joe Smith

Account                               Contact                                     Attention to

enter image description here

  • can you edit your question & add the formula you have in the contact full name field – Vamsi Krishna Sep 7 '15 at 23:58
  • Actually I found a Solution to address, I created an IF/OR Formula which picks from both the first and last names "IF(OR( Account__r.Name = Contact__r.Full_Name__c, Account__r.Name = Contact__r.FirstName, Account__r.Name = Contact__r.LastName), Null, "Attn: " & Contact__r.Full_Name__c)" – Medhanie Habte Sep 9 '15 at 16:30
1

First, I'd recommend you institute the use of a Validation Rule that requires a Contact to have a First Name in order for it to be saved. That appears to be part of the source of your problem.

To answer your real question, you could change your formula to look something like this:

IF(Account__r.Name =  Contact__r.FirstName & Contact__r.LastName ,, "Attn: "
 & Contact__r.FirstName & Contact__r.FullName__c)

I'm not quite certain why you're using Attn: Contact__r.FirstName & Contact__r.FullName__c in your formula above. Did you want the Account.Name someplace in the formula output instead?

As in: Contact__r.FirstName & " at " & Account.Name

If you don't use Account.Name, I'd expect to see the results as Attn: Joe Joe Smith, depending on whether the & gives you a space. If the & doesn't give you a space, you'd want to use & " " & both here and in code for the test of the initial condition.

  • This works fine, although the method I designed works well as well, and solves my issue. I basically want the Attn: to field for mail merges to only reference the contact if the contact/account names differ. – Medhanie Habte Sep 9 '15 at 16:44
  • It wasn't totally clear to me from the graphic you showed or from your question since the above duplicates the first name and you presumably only need one name reference. You should be able to use additional logic to test if the field isEmpty or isBlank, and either use a nested If statement or determine which field to use via the CASE function. – crmprogdev Sep 9 '15 at 16:50
  • Thanks for posting on SFSE. Community etiquette is to upvote well thought out questions and answers once you have sufficient reputation (15) plus help the rest of the community by marking a post as solving your question if it helped you resolve your issue. – crmprogdev Sep 9 '15 at 16:52

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.