- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-09-2022 09:02 AM
Hi, I have catalog client script where I need to get the dynamic URL of the current instance. I was reading that I need to create a script include and use a GlideAjax to call it. But is returning null. So far this is what I got.
Script Include
Client callable is set to true
var GetURL = Class.create();
GetURL.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getUrlDetails: function() {
var instanceURL = gs.getProperty('glide.servlet.uri');
return instanceURL;
},
type: 'GetURL'
});
Catalog client script
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
//Type appropriate comment here, and begin script below
var Sys = g_form.getValue('software_items');
var instance = new GlideAjax('GetURL');
instance.addParam('sysparam_name', 'url');
instance.getXML(GetUrlPlease);
function GetUrlPlease(response){
var answer = response.responseXML.documentElement.getAttribute("answer");
alert(answer);
}
if (newValue !== 'none') {
var url = answer + 'sp?id=sc_cat_item&sys_id=' + Sys + '&sysparm_category=69d0e41b1b5f8150a190ece0f54bcb4e',
_blank;
top.window.open(url, "_blank");
}
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-09-2022 09:25 AM
Replace below line in your code:
instance.addParam('sysparm_name', 'getUrlDetails');
Raghav
MVP 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-17-2023 12:28 AM
hi @Edxavier Robert can we use variable name in this URL like url = answer + current.variables.variable_name + .......
like this ?