Creating a URL that includes a line break for content fields

DonWalsh
Kilo Contributor

Hello!

I've been toying with the tools described here: https://wiki.servicenow.com/index.php?title=Navigating_by_URL

I can't seem to find how to include a linebreak for the work notes field in particular. The URL I'm playing with looks like this:

https://base URL/nav_to.do?uri=incident.do?sys_id=-1%26sysparm_query=work_notes=This is the first line of textThis is the second line of text

I'm hoping to construct this URL in such a way that it may separate the two lines of text with a line break. I've used since it matches hex encoding for spaces found in other URLs. Indeed, many URLs include a %20 for a simple space, but for some reason doesn't work add a line break, or seemingly anything at all.

Is there a way to accomplish a line break via URL navigation?

Thanks!
- Don

4 REPLIES 4

harikrish_v
Mega Guru

Hi Don,

Did you try storing it a variable and passing this variable thru the URL?

Regards,

Harikrishnan Vijayan
[img=180x60]http://analyticsindiamag.com/wp-content/uploads/2013/02/ibm_logo.jpg[/img]
ServiceNow Certified System Admin | ITIL V3 Foundation Certified


DonWalsh
Kilo Contributor

I have not. I'm the Knowledge Process Owner in my organization, and unfortunately I haven't been granted much access beyond ITIL user within the tool. The URL details I've come up with have come from a combination of external research and referencing INC templates within the tool.

When I examine these templates that have multi-line text to be inserted into content fields it's simply stored as multiline which I can't replicate within the URL. Basically, I'm not sure if I have the ability to store a line break as a variable, whether or not this has already been done and whether or not I can utilize such a variable given my access.

Any suggestions on how to proceed from here?


ok, what I was talking about, you will definitely need an admin access.
you can store your text in a multi_line[say u_multi_line] field on the form, then pass this along with your url


"/sys_user_list.do?sysparm_query=street="+current.u_multi_line [for server side]



"/sys_user_list.do?sysparm_query=street="+g_form.getValue("u_multi_line") [for client side]


Regards,

Harikrishnan Vijayan
[img=180x60]http://analyticsindiamag.com/wp-content/uploads/2013/02/ibm_logo.jpg[/img]
ServiceNow Certified System Admin | ITIL V3 Foundation Certified



Tim Deniston
Mega Sage
Mega Sage

Once you have built your URI into a string, use the JavaScript function encodeURI([uristring]). This worked well for me!



This an example of what I used in a UI Action to pull the Description from the current record and direct to the New Incident form.



var uristring = 'incident.do?sys_id=-1&sysparm_query=';


uristring += 'description=' + current.description;


var urifinal = encodeURI(uristring);



action.setRedirectURL(urifinal);



YMMV, however, since you do not have admin access.



The URI that is produced does not have any line break characters, but if you print out uristring and urifinal to the log, you will see the following:



uristring:


incident.do?sys_id=-1&sysparm_query=description=first line


second line


third line



finstring:


incident.do?sys_id=-1&sysparm_query=description=first%20linesecond%20linethird%20line