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

Onkar Pandav
Tera Guru

Hi,

Could you try with below line.

gs.getProperty("instance_name");

Priya Shid1
Kilo Guru

Hi Tarun,

you can use UI action for this find below code

action name-InstanceName

Onclick-f1()

function f1()
{
gsftSubmit(null,g_form.getFormElement(),'InstanceName');
}

if(typeof window =='undefined')
serverSideCode();

function serverSideCode()
{
var instanceName=gs.getProperty('glide.servlet.uri');
gs.addInfoMessage(instanceName);
action.setRedirectURL(current);
}

 

Please mark correct or helpful.

Jeffrey Siegel
Mega Sage

way easier than a script include:

 
var currentURL = this.location.href;
var str = currentURL.split(".")[0].split("//")[1];