Post

3 followers Follow
0
Avatar

Null in mutli-line text box

I'm a non-technical user attempting to use a calculation to concatenate address lines into one label to be printed. Some of these lines will be blank for some clients, and currently the calculation returns a "null" line. I'd like it to return nothing at all, and in fact not even create a new line. 

The fields available are:

  • Mail name 1
  • Mail name 2
  • Address 1
  • Address 2
  • Address 3
  • City
  • State
  • Zip

 

For most addresses, it returns something like:

(Mail name 1)
Null
(Address 1)
Null
Null
(City, State Zip)

I'd like it to return:

(Mail name 1)
(Address 1)
(City, State Zip)

 

Is this possible?

Jodi Christensen

Please sign in to leave a comment.

3 comments

0
Avatar

Hi Jodi,

yes, possible. Can you please share your current calculation (as screenshot and as text copy)?.

Rainer

Rainer Grabowski 0 votes
0
Avatar

@Recommended Mail Name 1+"\n"+@Recommended Mail Name 2+"\n"+@Preferred Street 1+"\n"+@Preferred Street 2+"\n"+@Preferred Street 3+"\n"+@Preferred City+" ,"+@Preferred State+" "+@Preferred Zip

Jodi Christensen 0 votes
0
Avatar

Hello Jodi,

this is one possible solution:

var mn1 = @Recommended Mail Name 1;
var mn1 = mn1 == null ? "" : mn1 + "\n";
var mn2  = @Recommended Mail Name 2;
var mn2 = mn2 == null ? "" : mn2 + "\n";
var ps1 =  @Preferred Street 1;
var ps1 = ps1 == null ? "" : ps1 + "\n";
var ps2 = @Preferred Street 2;
var ps2 = ps2 == null ? "" : ps2 + "\n";
var ps3 = @Preferred Street 3;
var ps3 = ps3 == null ? "" : ps3 + "\n";
var pcsz = @Preferred City+" ,"+@Preferred State+" "+@Preferred Zip;
mn1 + mn2 + ps1 +ps2 + ps3 + pcsz

Another one:

var arr = [@Recommended Mail Name 1,@Recommended Mail Name 2,@Preferred Street 1,@Preferred Street 2,@Preferred Street 3,(@Preferred City+" ,"+@Preferred State+" "+@Preferred Zip)];
arr.filter(function (i) {return i.length > 0;}).join("\n")

Rainer

Rainer Grabowski 0 votes