How to identify /n from a string and set its value in next line
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-01-2016 06:30 AM
HI All,
I have a string which is supposed to be identified with /n for next line and set the value in Incident Description field accordingly.
Example:
This is servicenow new version release \n please go through wiki for more details \n Contact support team for any issues \n Thanks
I want to set above in Incident field- description ,in this way where \n is meant for next line.
This is servicenow new version release
please go through wiki for more details
Contact support team for any issues
Thanks
Can Anyone put your thoughts on this or idea how do I proceed through scripting.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-01-2016 11:00 PM
Hi Loris,
Thanks for the idea.
Sorry about the confusion . Whole String contains \n and has to be set in incident 'Description' field. So will it automatically break the string and bring it next line??
I can not use g_form because it is coming via REST API in a field. I am doing this in Transform script.
Whole String has to be retrieved from the source field and has to be set in target 'description' with next lines.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-02-2016 02:05 AM
So you just need to set the 'Description' field to be a Multi-Line text (by setting the Mar Length in the dictionary to a value >= 256 ).
Any \n occurrence in the string will be rendered as new line
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-01-2016 06:58 AM
So I have tried the below code
[Client Side]
var str = "This is servicenow new version release \n please go through wiki for more details \n Contact support team for any issues \n Thanks";
g_form.setValue("short_description",str);
[Server Side]
var gr = new GlideRecord ("incident");
gr.get("71e0fa504750210042bd757f2ede2730");
var str = "This is servicenow new version release \n please go through wiki for more details \n Contact support team for any issues \n Thanks";
gr.short_description = str;
gr.update();
The variable named str in the above two pieces of code is the same you have posted.
They both (Client/Server sides) work fine, you just need to have the Short Description defined as Multi-Line text box in order to configure the capability of rendering the actual new lines.
For that matter, you would need to change the Dictionary of the Short Description field and set the Max Length field to a value greater than 255.
Ref: http://wiki.servicenow.com/index.php?title=Introduction_to_Fields#gsc.tab=0
See the String row:
String | Character string. For String type fields, a length of under 256 appears as a single-line text field and anything 256 characters or over appears as a multi-line text box. |
Regards,
Loris
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-02-2016 04:17 AM
So basically
source.u_description = "This is servicenow new version release \n please go through wiki for more details \n Contact support team for any issues \n Thanks"
required
target.description =
This is servicenow new version release
please go through wiki for more details
Contact support team for any issues
Thanks