Access property from client script

astickler
Kilo Explorer

I have a client-side UI Action for the Configuration Item table that adds a button to the form header and a context menu item to the list. The script needs to access one of my application's properties but I cannot work out how to do this.

 

I have tried:

var gr = new GlideRecord('sys_properties');

gr1.get("name", "myCat.myProp");

but this returns 'undefined'.

 

I have created a Business Rule (also for Configuration Item)   that pushes the property into g_scratchpad, and while this works when I click the form header button, the script debugger reports g_scratchpad as undefined when I use the list context menu (presumably because the Business Rule has not executed). I have tried setting the rule to execute 'before', 'after' and 'display' with no change.

 

Is there any better way for me to get the property?

Thanks,

Andrew

1 ACCEPTED SOLUTION

Best would be to get both values with one AJAX call.



Here is an example how to transport multiple values from server to client using JSON:


/* How to return multiple values via XML:


*


View solution in original post

19 REPLIES 19

Well, in order to get the value of the system property you need to query the sys_properties table.


GlideAjax allows you to do that with a callback function so the experience for your users will be very smooth and fast.



Basically, you trigger the client script, the client script does an AJAX call to the server, in return you get the URL and continue in your script using a callback function to trigger the pop-up window.


Interesting - that may work for me, but what if I wanted two properties? Would the
first callback have to issue a new AJAX call, and then I do my work in the second callback? If so, I suppose I need to assign the value of the first property to a global jscript variable so I can access it from the second callback.


Best would be to get both values with one AJAX call.



Here is an example how to transport multiple values from server to client using JSON:


/* How to return multiple values via XML:


*


I think you forgot the URL, but I worked it out myself.



thanks everyone for your help.


Sorry for that. Seems like my reply email was cut off in the middle of the code.


Let me know if you need the code.