How to get system properties client side?

peterraeves
Mega Guru

What's the client side equivalent of 'gs.getProperty'?

1 ACCEPTED SOLUTION

Chuck Tomasi
Tera Patron

I prefer to use a Display Business Rule and put the property in to a g_scratchpad variable. You can then use it in an onLoad script.



BR:



g_scratchpad.my_property = gs.getProperty('my.property');



CS:


var myProperty = g_scratchpad.my_property



I believe we covered this in episode 5 of TechNow.


TechNow Episode List


View solution in original post

14 REPLIES 14

Omkar Mone
Mega Sage

Hi 

 

You need to create client script like this

 

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

 

Script include

 

var HelloWorld = Class.create();HelloWorld.prototype = Object.extendsObject(AbstractAjaxProcessor, {   helloWorld:function() {  var property = gs.getProperty(“PropertyName”)return property; } ,       } });

 

Mark Correct if this helps.

Warm Regards,

Omkar Mone

find_real_file.png

www.dxsherpa.com

Hi Omkar,

 

Client script is already present and it is a UI page client script.

I have already tried the solution which you have recommended but that asynchronously provides the appropriate response and by then the UI would already be rendered.

I need to know a method where I can fetch the sys_property and then render the content based on that.

 

Mehtods tried:-

GlideAjax : -  responds after the UI is rendered alert for sys_property shows null.

g_scratchpad:- doesn't work (tried writing a on display BR on sys_ui_page table).

getXMLWait():- Does work but not sure whether to use as it is synchronous and may have performance impact.

 

Regards,

Zabeeulla.

Hi

If you want to render the content after the response you have to use Synchronous perspective.

It hampers performance when it takes time to fetch the value from the server.

Use getXMLWait() for the above requirement of your's with a callback function.

 

Mark correct if it helps.

Warm Regards,

Omkar Mone

find_real_file.png

www.dxsherpa.com

Can you explain the business requirement (not the technical requirement).

WHY are you trying to retrieve properties?

What is the functionality you are trying to accomplish?

What does this UI page do (and why)?

It could be that there are other (and possibly better) ways to do what you are a attempting. If you can provide us with some context, we may have other ideas than focusing on specific technical solutions that may lead to issues later.

himanshu_deep
Tera Contributor

A well explained video demo for this query.

 

https://www.youtube.com/watch?v=8r4e2UR2Mgg