The CreatorCon Call for Content is officially open! Get started here.

Get Name of the Instance in Ui action Client Script ??

Tarun2
Tera Contributor

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 .

1 ACCEPTED SOLUTION

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); }

}

View solution in original post

7 REPLIES 7

Harsh Vardhan
Giga Patron

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 . 

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

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); }

}

Priyanka Chandr
Mega Guru

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