+ Start a Discussion

Correcting Lookup(Account) value with a formula

We have a situation where we have several similar accounts names which makes it easy for emps to select the incorrect account. We have a lookup in a custom object that has a Lookup relationship to the account object. In this case, all account names are valid but for expense purposes, we want all expenses for the like names to go to one particular account.




TestCo - 1

TestCo - 2

TestCo, Inc. 


We know that any accounts that contain the name TestCo should actually be TestCo, Inc. when reporting expenses.


I'm trying to create a formula that will update the Lookup(account) to the desired account name when the incorrect account has been selected.


Such as: 

IF(Contains(Client__r.Name, "TestCo"),"TestCo, Inc.", "")


The above formula returns - Error: Formula result is data type (Text), incompatible with expected data type (true or false).


All other accounts (without TestCo) should continue as normal.


Workflow rules can't update this field as well... Which would have been real easy to do.


If possible, Id like to stay away from triggers since I really suck at them... but if there is no other option, I'll be open to attempt it.


Suggestions greatly appreciated.


Thanks you in advance.

Best Answer chosen by Admin (Salesforce Developers) 

This is tricky without the aid of a trigger/workflow...

An alternative is to have the user make the correction:

Use the validation rule:

AND ( CONTAINS(Client__r.Name,'TestCo'), Client__r.Name!='TestCo, Inc.' )


In your error message, say something along the lines: This <object> should be linked to the Testco, Inc. client...