Search code examples
xpagescomputed-field

Displaying a computed field with multiple lines? (xpages)


OK, I have a customer name and address and simply want to display this in one computed field instead of separate lines in a table to save real estate. I've tried several iterations of @newline but to no avail. Can someone give me some guidance?

I would also like to NOT include Address2 if it's blank. I'm new to javascript. Thanks for your help.

var a = document1.getItemValueString("CompanyName");
var b = document1.getItemValueString("Address1");
var c = document1.getItemValueString("Address2");
var d = @Char(13);
a + @NewLine() + b + "<br>" + c;

Solution

  • Set property escape="false" in computed field and add <br /> whenever you want a newline.

    You can set this property in properties tab selecting content type "HTML" too:

    enter image description here

    Your code would be

    var a = document1.getItemValueString("CompanyName");
    var b = document1.getItemValueString("Address1");
    var c = document1.getItemValueString("Address2");
    a + "<br />" + b + (c ? "<br />" + c : "");