Concatenation using formula field

I want to concatenate four fields in formula field with comma separated value.
This is not possible as with normal concatenation you will see additional comma if one of the value is blank.
You have to use different combination to achieve this but it will be lengthy process.

Suppose, FirstName__c = Utkarsha
                 SecondName__c = Pravin
ThirdName__c = Raj
FourthName__c = Rutuja

Then I want if all are blank then show null value else Utkarsha, Pravin, Raj, Rutuja
Suppose ThirdName__c is blank then it will show Utkarsha, Pravin, Rutuja

I have used SUBSTITUTE functionality to achieve this.


IF(
AND(ISBLANK(FirstName__c),ISBLANK(SecondName__c),ISBLANK(ThirdName__c),ISBLANK(FourthName__c)),
 NULL,
SUBSTITUTE(
    IF(
        NOT(ISBLANK(FirstName__c)),
        FirstName__c+ ", ",
        NULL
    ) +
    IF(
        NOT(ISBLANK(SecondName__c)),
        SecondName__c + ", ",
        NULL
    ) +
    IF(
        NOT(ISBLANK(ThirdName__c)),
        ThirdName__c + ", ",
        NULL
    ) +
    IF(
        NOT(ISBLANK(FourthName__c)),
        FourthName__c + ", ",
        NULL
    ) + ".",
    ", .",
    NULL)



Comments

Popular posts from this blog

Syncing And Unsyncing Quote With Opportunity Using Flow And Process Builder