EncodeURLForQueryString function

Syntax

EncodeURLForQueryString(URLString)

Description

Use the EncodeURLForQueryString function to encode URLString for use in a query string parameter in a URL. All characters outside the Unicode Basic Latin block (U+0020 — U+007F) are encoded, with the exception of the characters in the table below which are not encoded as they are typically valid in a query string.

If the link is constructed in a page, and the value is a link field, you should not call EncodeURL to encode the entire URL, as the PeopleSoft Pure Internet Architecture does this for you. You still need to unencode the parameter value when you retrieve it, however.

Always encode each field value being added directly to query strings using EncodeURLForQueryString.

The following table lists characters in the Unicode Basic Latin block that are not encoded by the URLEncodeForQueryString function.

Character (Glyph) Description (Unicode Character Name)

(

Left parenthesis

)

Right parenthesis

*

Asterisk

-

Hyphen (minus sign)

.

Period (full stop)

_

Underscore

Parameters

Parameter Description

URLString

Specify the string you want encoded. This parameter takes a string value.

Returns

An encoded URL string.

Example

In an Internet Script, to construct an anchor with a URL in a query string parameter, do the following:

&url = "http://host/psp/ps/EMPLOYEE/HRMS/s/EMPL_INFO.FieldFormula.IScript_EMPL_⇒
INFO?emplid=1111&mkt=usa"
&href = %Request.RequestURI | "?" | %Request.QueryString | "&myurl=" | EncodeURLForQueryString(&url); 
%Response.WriteLine("<a href= " | EncodeURL(&href) | ">My Link</a>");

The following uses a generic method to find, then encode, the URL, for the external link:

&StartPos = Find("?", &URL, 1); 
&CPColl = &Portal.ContentProviders; 
&strHREF = EncodeURLForQueryString(Substring(&URL, &StartPos + 1, Len(&URL), &StartPos)); 
&LINK = &Portal.GetQualifiedURL("PortalServlet", "PortalOriginalURL=" | &CPColl.ItembyName(&CP_NAME).URI | "?" | &strHREF);