kevclark
Tera Contributor

This is just a quick article which I hope people will find useful.

I was using Flow Designer to populate a task record's Description field using the "Create Task Record" action that comes with the Flow Designer Service Catalog plugin.

I needed to insert line-breaks into the Description field so that I could separate fields from the Catalog Variables - for example:

Do something with this Widget.

Name of submitter: <variables.submitter>

Name of widget: <variables.widgetname>

After getting some helpful suggestions online (hi SNdevs!) I found a solution for adding line breaks was to encapsulate the entire string (including data pills) in a Javascript string using \n line breaks. 

For example, the syntax for the above description would be:

javascript: "Do something with this Widget. \n Name of Submitter: {{submitter data pill}} \n Name of Widget: {{widgetname data pill}}"

I hope someone else finds this useful!  

Comments
LaurentChicoine
Tera Guru

Thanks a lot for sharing, this will be really useful to me for Automated tests (ATF). I didn't have a good way to validate multi-line fields and was forced to make multiple contains condition for every line which is not the same as testing for the exact string.

Edit: After further usage, ATF validations require to use \r\n for a new line instead of simply \n.

hnie
Tera Contributor

Thanks for sharing 🙂

I can see that we have changed our "Description" field years ago to a HTML field rather than the ootb string.

Result is that the following is printed in the description field when the catalog task is created:

<p data-tinymcerootblock

Any ideas on how to work around it?

kevclark
Tera Contributor

I'm not entirely sure, but you may need to construct the entire value in the whatever the desired target HTML needs to be, so something like:

javascript:"<span>hello world</span></ br>this is the next line.</ br>then the next line.</ br>" 
hnie
Tera Contributor

Hey,

I managed to get this to work - You just need to Shift+Enter when adding a new line in the HTML field in the flow designer - Then it actually works! 🙂

https://docs.servicenow.com/bundle/london-platform-administration/page/use/using-forms/concept/c_InsertALineBreak.html

kevclark
Tera Contributor

Nice!  Will have to test next time I'm working in Flow Designer.

Meshia
Kilo Guru

thanks so much. This was sooooooo helpful Kev.

bpolo
Tera Guru

Hi Kev

This was super helpful for me too ... Thanks very much!!!

Team Carl
Tera Explorer

Thanks for this - I used it on the Virtual Agent, which worked like a dream!

 

javascript: "Some text\n\nDescription: {{vaInputs.description}} \n\nSome more text"

Version history
Last update:
‎01-31-2019 09:14 PM
Updated by: