Expand my Community achievements bar.

Adobe Campaign Community Lens 8th edition is out!

Adding default value when first name personalization is blank


Level 2


How can I add a default value to my firstName personalization in my email, such as "Valued Customer" if firstName is empty? Right now, it shows as a blank space followed by a comma).


<span class="nl-dce-field mobile_header_text nl-dce-done" id="span161662637290731" data-nl-expr="/context/profile/firstName" data-nl-type="string" data-contenteditable="false" data-nl-format="datetime">First name (firstName)</span>


Thanks in advance.




Topics help categorize Community content and increase your ability to discover relevant content.

4 Replies


Employee Advisor

you could define a dynamic content and then use a condition "firstname is not empty" and the default value


Level 1

I would go with Ramon's solution, but you could use a content block as well.


Here is the code of one we have already in place in our ACS:


// Displays a greeting formula appropriate for the profiles' fields
// populated in the database (first name, last name and title)
// The following table defines the formula to use in each case
// (#0 is replaced with the title, #1 with the first name and #2 with the last name)

var aGreetings =         // **bleep** Fir Las
['Hello,'         ,    //
 'Hello,'         ,    //          X
 'Hello,'         ,    //      X
 'Hello #1 #2,'   ,    //      X   X
 'Hello #0,'      ,    //  X
 'Hello #0 #2,'   ,    //  X       X
 'Hello #0,'      ,    //  X   X
 'Hello #0 #1 #2,'];   //  X   X   X

var aField = [context.profile.salutation,  // field corresponding to #0
              context.profile.firstName,   // field corresponding to #1
              context.profile.lastName];   // field corresponding to #2

var iIndex = 0, iCount = aField.length;
for( i=0 ; i<iCount ; i++ )
  if( aField[i] != '' )
    iIndex += Math.pow(2,(iCount-i-1));

var sToDisp = aGreetings[iIndex];
sToDisp = sToDisp.replace(/#0/, aField[0]);
sToDisp = sToDisp.replace(/#1/, aField[1]);
sToDisp = sToDisp.replace(/#2/, aField[2]);


You can use the code above and modify it to only use the first name if exist.


Level 2
@Xyborg - thanks so much for the info. I will check out Ramon's first and then yours.