Access GlideSystem from UI Script?

adevezin
Giga Contributor

Hello,

so while in a UI Script i am not able to use 'gs' to access the glidesystem. Is there another way to allow me to access? I specifically need to run gs.getProperty() from a UI Script.

7 REPLIES 7

mamann
Mega Guru

Since you're using a UI Script, I can assume you're not running this on a form/table. If so, you could use a display business rule and put the data into g_scratchpad.



In that case, you'll need to make an Ajax call to the Server, using GlideAjax to access that property, then return it to the client.



g_scratchpad usage: Example - retrieve server data using g_scratchpad


GlideAjax: Examples of asynchronous GlideAjax


adevezin
Giga Contributor

That seems to be where i need to go. But it doesnt explain what table to define this on. If its just for a ui script its unclear what table to put the business rule on. So g_scratchpad is always undefined in my UI Script.


If you need to use the code from the UI Script on a specific table, you may be better off using a Client Script instead.


If you can give us further info on what you're trying to accomplish, I can give you more direction on the best approach.


adevezin
Giga Contributor

I am editing a UI page and using angular.


The original SN code is


<g:ui_reference name="item_ref_field" query="sys_class_nameNOT IN$[gs.getProperty('glide.sc.item.cannot_add_to_request')]" table="sc_cat_item"   />



Since im using angular i cannot use these fields. But it is a basic GlideRecord look up. So I am trying to use a UI Script to perform the same query. However UI Scripts do not have access to the GlideSystem. I used the above method. However, 1) I am not sure if my business rule is running. 2) g_scratchpad is undefined in the UI Script