- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-22-2016 01:10 AM
How to get url parameter value in the Client Script Service Portal?
Please advise.
Thanks!
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-22-2016 01:53 AM
Hi,
You can add this line to the server side code:
data.parameter_value = $sp.getParameter("parameter_name");
and access the same in client using :
($scope.data.parameter_value);
Please make sure $scope is present in your function declaration.
Regards,
Indumathi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-22-2016 01:53 AM
Hi,
You can add this line to the server side code:
data.parameter_value = $sp.getParameter("parameter_name");
and access the same in client using :
($scope.data.parameter_value);
Please make sure $scope is present in your function declaration.
Regards,
Indumathi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-22-2016 09:00 PM
Hi Indumathi,
Thanks a lot.
This had solved my problem
Best regards,
Joan

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-22-2016 01:57 AM
Use $location. For more info check AngularJS .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-06-2017 09:20 AM
Now in Istanbul (not sure if it's a recent patch or what) you can apparently just use this.location.href to get the current page's URL in the service portal, via catalog client script.
For example:
var yourParamValue = getAllUrlParams(this.location.href)['YOUR_PARAM_NAME'];
/**
* Get the values of each URI param as properties of an object (name-value pairs).
* @param url
* @returns {{}}
* @example - In the URL www.google.com/page?urip=pickles&otheruriparam=bananas, you could use getAllUrlParams().urip to get "pickles".
*/
function getAllUrlParams(url) {
// get query string from url (optional) or window
var queryString = url ? url.split('?')[1] : window.location.search.slice(1);
// we'll store the parameters here
var obj = {};
// if query string exists
if (queryString) {
// stuff after # is not part of query string, so get rid of it
queryString = queryString.split('#')[0];
// split our query string into its component parts
var arr = queryString.split('&');
for (var i = 0; i < arr.length; i++) {// separate the keys and the values
var a = arr[i].split('=');
// in case params look like: list[]=thing1&list[]=thing2
var paramNum = undefined;
var paramName = a[0].replace(/\[\d*\]/, function(v) {paramNum = v.slice(1, -1);
return '';
});
// set parameter value (use 'true' if empty)
var paramValue = typeof(a[1]) === 'undefined' ? true : a[1];
// (optional) keep case consistent
paramName = paramName.toLowerCase();
paramValue = paramValue.toLowerCase();
// if parameter name already exists
if (obj[paramName]) {// convert value to array (if still string)
if (typeof obj[paramName] === 'string') {obj[paramName] = [obj[paramName]];
}// if no array index number specified...
if (typeof paramNum === 'undefined') {// put the value on the end of the array
obj[paramName].push(paramValue);
}// if array index number specified...
else {// put the value at that index number
obj[paramName][paramNum] = paramValue;
}}
// if param name doesn't exist yet, set it
else {obj[paramName] = paramValue;
}}
}
return obj;
}