How to populate a textarea with multiple newlines on a form in CA Service Catalog

Document ID : KB000125356
Last Modified Date : 28/01/2019
Show Technical Document Details
Introduction:
N/A
Background:
N/A
Environment:
Windows
Instructions:
Please check the below script to get this accomplished.
 
1. In SC/Catalog/Forms/Forms, Create a form with a component of type 'text area'.
The _id of the form  = form2
The _id of the field = txta
 
2. And then add the following script to the form:
{
  nl : function() { 
    ca_fdSetTextFieldValue('form2', 'txta', 'l1' + '\n' + 'l2'); 
    }
}
 
3. Next, in the 'onLoad' of the field 'txta', enter the function-call: ca_fd.js.nl()
4. Save the form-change.
5. Open a new request for the service-option with this form and the field will get a 'default' multi-line value.

Note:
When the 'Value' in the form's text-area component needs to be set to: 
'This is a test\nof a \nmulti-line string.

  nl : function() {
  ca_fdSetTextFieldValue(ca_fd.formId, 'txta', ca_fdGetTextFieldValue(ca_fd.formId, 'txta').replace(/\\n/g, '\n'));
}