How to concatenate text fields conditionally
Oct 02, 2018
I have a course in which the users will select 3 out of 7 behaviors to commit to over the next 30 days.
What I would really like would be to format the email so that the body looks like:
Here are the behaviors I'm committed to practicing for the next 30 days:
Right now, I'm using semicolons to separate the commitments instead of line breaks because if the user selects behaviors 1, 5, and 7 there would be a bunch of line breaks between 1 and 5.
So... how do I get the variable "commitments" to concatenate only the populated commitment variables?
var player = GetPlayer();
var email = player.GetVar('email');
var commitment1 = player.GetVar('commitment1');
var commitment2 = player.GetVar('commitment2');
var commitment3 = player.GetVar('commitment3');
var commitment4 = player.GetVar('commitment4');
var commitment5 = player.GetVar('commitment5');
var commitment6 = player.GetVar('commitment6');
var commitment7 = player.GetVar('commitment7');
var commitments = commitment1 + '; ' + commitment2 + '; ' + commitment3 + '; ' + commitment4 + '; ' + commitment5 + '; ' + commitment6 + '; ' + commitment7;
var subject = 'My Commitments to Reducing Escalations Behaviors';
var emailBody = 'Hi,' + '\n' + '\n' + 'Here are the behaviors I am committed to practicing for the next 30 days: '+ commitments + '\n' + '\n' + 'Thank you,' + '\n' + '\n';
This discussion is closed. You can start a new discussion or contact Articulate Support.