- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-26-2020 12:06 AM
Hi ,
How to Get Name of the instance in Ui action Client Script
Requirement : To Create a Url link for Ui page ( Same code should work in MUltiple Instances (Dynamic Code)).
Below code is not working in Script . ( only works in Background Scripts)
* gs.getProperty('glide.servlet.uri') + gs.generateURL(strTableName, strSysID)
What to do now ??
Kindly Help me in Getting Name of the Instance in Ui action Client Script .
Thankyou .
Solved! Go to Solution.
- Labels:
-
Script Debugger
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-26-2020 12:38 AM
script include:
var HelloWorld = Class.create();
HelloWorld.prototype = Object.extendsObject(AbstractAjaxProcessor, {
helloWorld:function() {
var instanceURL = gs.getProperty('glide.servlet.uri');
return instanceURL;
} ,
type: 'HelloWorld'
});
UI Action client script part:
function onClick(g_form) {
var ga = new GlideAjax('HelloWorld');
ga.addParam('sysparm_name', 'helloWorld');
ga.getXML(HelloWorldParse);
function HelloWorldParse(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
alert(answer); }
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-26-2020 12:10 AM
try to use here glide ajax and write the server side script inside there and then call that script include on your client script of the UI action .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-26-2020 12:27 AM
This is my workspace ui action button script.
Can we write GlideAJAX code inside it .
function onClick(g_form) {
// Current context (anonymous method executed by Agent Workspace)
var tb = g_form.getValue("name");
var str= g_form.getRelatedListNames();
var res = str.toString();
var col= res.substring(0, res.indexOf('.'));
openUrl("https://devxxx.service-now.com/ui_page.do?sys_id=f4d64f0e2f6b00108490dcb6f699b611&sysparm_category="+ tb+ "&sysparm_category1="+ col);
}
Thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-26-2020 12:38 AM
script include:
var HelloWorld = Class.create();
HelloWorld.prototype = Object.extendsObject(AbstractAjaxProcessor, {
helloWorld:function() {
var instanceURL = gs.getProperty('glide.servlet.uri');
return instanceURL;
} ,
type: 'HelloWorld'
});
UI Action client script part:
function onClick(g_form) {
var ga = new GlideAjax('HelloWorld');
ga.addParam('sysparm_name', 'helloWorld');
ga.getXML(HelloWorldParse);
function HelloWorldParse(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
alert(answer); }
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-26-2020 12:31 AM
Hi,
refer this code this is one example
HTML of the UI page:
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<a href="javascript:showLink()" >Dynamic link</a>
</j:jelly>
Client script of the UI page:
function showLink()
{
var url = window.location.href;
var str = url.split(".")[0];
window.open(str+'.service-now.com');
}
If this solves your issue kindly mark it correct and helpful
Thanks
Priyanka