Adding default value when first name personalization is blank

Avatar

Avatar
Level 1
terricurry
Level 1

Likes

0 likes

Total Posts

19 posts

Correct reply

0 solutions
View profile

Avatar
Level 1
terricurry
Level 1

Likes

0 likes

Total Posts

19 posts

Correct reply

0 solutions
View profile
terricurry
Level 1

25-03-2021

Hello,

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.

 

Terri

Accepted Solutions (0)

Answers (2)

Answers (2)

Avatar

Avatar
Boost 250
Employee
ramon_bisswanger
Employee

Likes

271 likes

Total Posts

397 posts

Correct reply

199 solutions
Top badges earned
Boost 250
Affirm 100
Give Back 25
View profile

Avatar
Boost 250
Employee
ramon_bisswanger
Employee

Likes

271 likes

Total Posts

397 posts

Correct reply

199 solutions
Top badges earned
Boost 250
Affirm 100
Give Back 25
View profile
ramon_bisswanger
Employee

05-04-2021

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

Avatar

Avatar
Affirm 1
Level 1
Xyborg
Level 1

Likes

0 likes

Total Posts

2 posts

Correct reply

1 solution
Top badges earned
Affirm 1
View profile

Avatar
Affirm 1
Level 1
Xyborg
Level 1

Likes

0 likes

Total Posts

2 posts

Correct reply

1 solution
Top badges earned
Affirm 1
View profile
Xyborg
Level 1

08-04-2021

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]);
document.write(sToDisp);
%>

 

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