How to identify /n from a string and set its value in next line

snowuser111
Kilo Guru

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.

8 REPLIES 8

Kalaiarasan Pus
Giga Sage

This works just fine



g_form.setValue('description','This is servicenow new version release \n please go through wiki for more details \n Contact support team for any issues \n ');


Kalaiarasan Pus
Giga Sage

I believe even the server side using current should work fine.


Sorry forgot to mention.


The string value will be dynamic and has to be retrieved from a field, so have to set the value from that field and set in Description.


Should not be a problem.


You can get the value by using


var str = g_form.getValue("FIELD_NAME");


then set it by using


g_form.setValue("short_description",str);



The important thing is that the short_description field is configured as multi line text (Max Length >= 256).



It's not very clear if you have \n or /n in your input string, anyway, in case you have to replace all the occurrences of /n to be \n (the actual new line character), you can use the replace() JavaScript function. So you will have something like:



var str = g_form.getValue("FIELD_NAME");


var strReplaced = str.replace ("/n","\n");


g_form.setValue("short_description",strReplaced);



Regards,


Loris