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
AshwAshw 

display account name with out account tail name

Is it possible to display account name with out accounts tail name 
example account name: Apple cooperation limit but need to display only Apple 
              Account name: salesforce Pvt. Ltd need to display only salesforce in vf page this way only account names on vf page with out tail names. Please provide your valuable suggestion 

Best Answer chosen by Ashw
Abhishek BansalAbhishek Bansal
Hi,

If you want to change the name of all accounts than you can do something like below :

List<Account> accNameList = [Select Name from Account];
for(Account acc : accNameList ){
    acc.Name = acc.Name.split(' ')[0];
}

Now your accNameList will hold all the accounts with modified name.

Let me know if you need more help on this.

Thanks,
Abhishek

All Answers

Abhishek BansalAbhishek Bansal
You can do something like this :

String accName = Account.Name.split(' ')[0];

It will return you the first word of the account name which is your requirement.
Now use this string in your VF page where you want to show account name.

Let me know if you need more help on this.

Thanks,
Abhishek
AshwAshw
Hi Abhishek
thanks for ur reply, If I use array [0] will that returns only one record or all the records from account. I want this to work on all the account records to display on vf page 
Abhishek BansalAbhishek Bansal
Hi,

If you want to change the name of all accounts than you can do something like below :

List<Account> accNameList = [Select Name from Account];
for(Account acc : accNameList ){
    acc.Name = acc.Name.split(' ')[0];
}

Now your accNameList will hold all the accounts with modified name.

Let me know if you need more help on this.

Thanks,
Abhishek
This was selected as the best answer
AshwAshw
Thanks Abhishek its working thank man, Abhishek do you have any sample code to implement Synonym lookup - Dictionary lookup can we do this in salesforce