How in insert a line break in a custom field of th...
# ask-stanley-ai
j
How in insert a line break in a custom field of the long text type in SuiteScript using setText?
c
AI generated answer (using internal Slack threads):
To insert a line break in a custom field of the long text type in SuiteScript using
setText
, you can use the newline character (
\n
). However, please note that the behavior might vary depending on where you are viewing the field. If you are viewing it in a UI context, the newline character might not render as a line break. Here is an example of how you can use the newline character in `setText`:
Copy code
javascript
record.setText({
    fieldId: 'custrecord_tran_packages_tran_link',
    value: 'Sales Order #'+orderNum + '\n' + 'Additional Line',
    ignoreFieldChange: true
});
In this example, 'Additional Line' will appear on a new line in the field 'custrecord_tran_packages_tran_link'. If you are dealing with a rich text field and you are seeing HTML tags like
<br>
instead of actual line breaks, you might need to replace these tags with newline characters. Here is an example of how you can do this:
Copy code
javascript
var textWithBr = record.getValue({fieldId: 'custrecord_rich_text_field'});
var textWithNewline = textWithBr.replace(/<br>/g, '\n');
record.setValue({fieldId: 'custrecord_rich_text_field', value: textWithNewline});
In this example, all
<br>
tags in the 'custrecord_rich_text_field' field are replaced with newline characters. ****** Disclaimer: This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes. ******
Slack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.835609198
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.829052567
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.817839622
Please provide your feedback on this answer.