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

book

Article ID: 125356

calendar_today

Updated On:

Products

CA Service Catalog CA Service Management - Asset Portfolio Management CA Service Management - Service Desk Manager

Issue/Introduction

N/A

N/A

Environment

Windows

Resolution

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'));
}