2

I'm getting document history, adding "\n" and existing document history. Code executes without any error. But when I see it in web everything on one line. In notes client, document history is shown as one line of activity.

Tried with @Newline and same issue.

What I'm doing wrong?

Thanks in advance.

Here is sample code:

var myvar="\n"
var h=getComponent("docHistory1").getValue();
var msg="Stage 2 - LAB Manager approved and completed check. Send to Chemist: " + unm + "  + dt1;
document1.setValue("DocHistory", h + myvar + msg);
document1.save();
Mohan Gangan
  • 127
  • 11

2 Answers2

4

Use a Multiline Edit Box xp:inputTextarea instead of a Computed field xp:text and set it to Read only readonly="true".

As an alternative you could still use a Computed field replacing all '\n' with '<br />' and setting escape="false".

Knut Herrmann
  • 30,880
  • 4
  • 31
  • 67
  • Thank you for your quick answer. readonly = "true" does not save the component to notes document. After readonly flag it saves the component. Thanks again – Mohan Gangan Apr 07 '14 at 20:38
  • Yes, `readonly="true"` is only necessary if field doesn't have to be editable. I thought you just wanted to show the history. Then without readonly parameter it's even easier :) – Knut Herrmann Apr 07 '14 at 20:44
  • Thank you very much. I kept it read only, added data as notes field (which I forgot to mention in my previou post. I do apologize for that) and changed the value thru button. It saved the value but
    appeared as it is as shown here: 0
    Stage 2 Accepted:- Mohan Gangan - 4/7/14: test1. But goodnews is @NewLine function adds new line. I do appreciate your quick help. Thanks again.
    – Mohan Gangan Apr 07 '14 at 20:58
  • If you want to apear `
    ` as a newline then you have to set `escape="false"`.
    – Knut Herrmann Apr 07 '14 at 20:59
0

Just to give an alternative solution, you could use a style on the computed text component with "white-space:pre" (or pre-line or pre-wrap, see this for the differences) and that would preserve the newlines in the content.