Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

What is the best way to call system property in a client script (script include) for a catalog item ???

Rathan1
Tera Contributor

What is the best way to call system property in a client script (script include) for a catalog item ???

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

you cannot get system property value in client side directly.

you need to use GlideAjax for this and return the property value from the ajax function

Example

Script Include: It should be client callable

var checkRecords = Class.create();
checkRecords.prototype = Object.extendsObject(AbstractAjaxProcessor, {

	checkRecordPresent: function(){
		return gs.getProperty('property_name'); // name of property here
	},

	type: 'checkRecords'
});

Client Script:

var ga = new GlideAjax('checkRecords');
ga.addParam('sysparm_name', "checkRecordPresent");
ga.getXMLAnswer(function(answer){
	if(answer != ''){
		alert(answer); // this gives you the property value
	}
});

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

View solution in original post

8 REPLIES 8

umaaggarwal
Giga Guru

gs.getProperty("propertyName") can be used in script include or Business rule, workflow etc

Mohith Devatte
Tera Sage
Tera Sage

hello Rathan ,

you can call a system property in server side script only which is a script include in your case like below 

Not only in script include , you can call it in any server side scripting 

gs.getProperty('your+property_name');

Hope this helps 

mark my answer correct if this helps you

 

umaaggarwal
Giga Guru

In client script you can use it using g_scratchpad’

 

So capture the property value in display business rule using g_scratchpad  and then access the g_scrtchpad variable in any client script 

 

Please mark my answers helpful and correct if they really helped

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

you cannot get system property value in client side directly.

you need to use GlideAjax for this and return the property value from the ajax function

Example

Script Include: It should be client callable

var checkRecords = Class.create();
checkRecords.prototype = Object.extendsObject(AbstractAjaxProcessor, {

	checkRecordPresent: function(){
		return gs.getProperty('property_name'); // name of property here
	},

	type: 'checkRecords'
});

Client Script:

var ga = new GlideAjax('checkRecords');
ga.addParam('sysparm_name', "checkRecordPresent");
ga.getXMLAnswer(function(answer){
	if(answer != ''){
		alert(answer); // this gives you the property value
	}
});

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader