function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
HTANIRSHTANIRS 

How to Split FirstName and LastName

Hello All,

I need help in splitting FirstName and LastName in Account.

My Requirement:
If FirstName is empty, break LastName by first space character and use first part of it as firstname and the remaining as lastname.

How can I achieve this ? Trigger or Config.

Kindly Suggest.

Thanks.
Best Answer chosen by HTANIRS
Guru Vemuru 11Guru Vemuru 11
Hi Htanirs,
Please try these Two formulas
First Name---->If( CONTAINS(Name, " "),(LEFT(Name, FIND( " ", Name ) -1 )), (LEFT( Name , LEN(Name)- 2)))
Last Name---->If( CONTAINS(Name, " "),(RIGHT(Name, LEN(Name) - FIND(" ",Name))),RIGHT(Name, 2))

Letme know if it is working 

Regads
Guru vemuru
 

All Answers

Guru Vemuru 11Guru Vemuru 11
Hi Htanirs,
It is possible with configuration only, but after one space this formula will consider remaining part as a last name.
See below formula
LEFT(Name, FIND( " ", Name ) -1 ) for first name
RIGHT(Name, LEN(Name) - FIND(" ",Name))  for last name

please refer below post
https://success.salesforce.com/answers?id=90630000000Zii1AAC

Regads
Guru Vemuru
HTANIRSHTANIRS
Hi Guru,

Thanks. I have one scenario where firstname is empty and lastname does not have space. Then I need to split last 2 characters and put them in lastname and remaining in firstname.

Please let me know how to solve.
Guru Vemuru 11Guru Vemuru 11
Hi Htanirs,
Please try these Two formulas
First Name---->If( CONTAINS(Name, " "),(LEFT(Name, FIND( " ", Name ) -1 )), (LEFT( Name , LEN(Name)- 2)))
Last Name---->If( CONTAINS(Name, " "),(RIGHT(Name, LEN(Name) - FIND(" ",Name))),RIGHT(Name, 2))

Letme know if it is working 

Regads
Guru vemuru
 
This was selected as the best answer
HTANIRSHTANIRS
Hi Guru,

Thanks for your help. This is working fine.