You need to sign in to do that
Don't have an account?
self learning 8
Display list of values with comma separation but for the last value before need to display and instead comma
now following code displaying like a,b,c,d
But I want to display like a,b,c and d
Code is :
String dear = 'Hello';
boolean first = true;
for(Account a : accs)
{
if(first)
{
dear += a.Salutation+ ' ' + a.lastname;
first = false;
continue;
}
// dear += ' and ' + a.Salutation+ ' ' + a.lastname;
dear += ' , ' + a.Salutation+ ' ' + a.lastname;
}
dear += ',';
Opp.customer__c = dear;
update opp;
But I want to display like a,b,c and d
Code is :
String dear = 'Hello';
boolean first = true;
for(Account a : accs)
{
if(first)
{
dear += a.Salutation+ ' ' + a.lastname;
first = false;
continue;
}
// dear += ' and ' + a.Salutation+ ' ' + a.lastname;
dear += ' , ' + a.Salutation+ ' ' + a.lastname;
}
dear += ',';
Opp.customer__c = dear;
update opp;
All Answers
You can use any of the following approaches for this:
1.
2.
3.
Hope this will help you.
Thanks
If I am displaying 3 account it should be like a,b and c
If I am displying 4 account it should be like a,b,c and d