- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2014 09:07 AM
I'm working on a Transform Map, and I've got a good handful of fields that don't quite have an appropriate target field, so I'd like to stitch them together and write them all to a journal field (Work Notes, specifically). Ideally, I'd do this with
target.work_notes = "[Column A Name]\n" + source.column_a + "\n\n" +
"[Column B Name]\n" + source.column_b;
to get:
[Column A Name]:
[Column A Value]
[Column B Name]:
[Column B Value]
The trick is: nothing past the first newline gets written to the field. I just end up with
[Column A Name]:
and nothing else.
This makes some sense: I know I parse journals into individual entries by splitting them on "\n\n"; but I also know that I can enter newlines from the actual interface and it handles them just fine; and it's stopping at the first "\n".
Sure, I could do
[Column A Name]: [Column A Value] [Column B Name]: [Column B Value]
But that just looks bad, doesn't it?
So: how do I indicate, via a script, that I'd like there to be a newline within a single journal entry?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2014 09:11 AM
I believe the problem is you should have a leading "u_" for the column names:
target.work_notes = "[Column A Name]\n" + source.u_column_a + "\n\n" + "[Column B Name]\n" + source.u_column_b;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2014 09:11 AM
I believe the problem is you should have a leading "u_" for the column names:
target.work_notes = "[Column A Name]\n" + source.u_column_a + "\n\n" + "[Column B Name]\n" + source.u_column_b;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2014 05:04 AM
You know, I don't think it was the missing "u_" (the above was just stuff I wrote to demonstrate what I was doing), but it did turn out to be some stupid javascript syntax error that I missed thanks to fixating on the newline thing.
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-21-2021 08:41 AM
Maybe the other guys are able to get "\n" to work but this is an old thread so maybe it's no longer working in latest OOTB ServiceNow? At least it is not working for me...
So I instead added the following to the string anytime i needed a line break to show up:
"[code]<br />[/code]"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-21-2021 08:42 AM
Maybe the other guys are able to get "\n" to work but this is an old thread so maybe it's no longer working in latest OOTB ServiceNow? At least it is not working for me...
So I instead added the following to the string anytime i needed a line break to show up:
"[code]<br />[/code]"