Jelly and RP.getWindowsProperties

poyntzj
Kilo Sage

I am struggling to get a table name through to a ui page

The UI action has

dialog.setPreference("table_name", g_form.getTableName());

the ui page has

<g:ui_table>

  <g:set var="jvar_tablename" value="$[RP.getWindowProperties().get('table_name')]"/>

and a bit later on

gr.addQuery('table',jvar_tablename);

but it is not seemingly being passed the value

I have plenty of other ui pages that are working so I am a little bemused

for example, this is from one that works

UI action

dialog.setPreference("sysid", sysid);

UI Page

<g:ui_form>

<!-- Holds the Incident ID for use in HTML and the processing script -->

<j2:set var="jvar_incident_id" value="$[RP.getWindowProperties().get('sysid')]"/>

Only difference that I see is that the non working one is using a ui_table and the one that works is using ui_form, but I cannot see this making that much of a difference.

Any ideas would be appreciated

Cheers

1 ACCEPTED SOLUTION

This worked for me in the end



<g:evaluate jelly="true">


  var table_name = RP.getParameterValue('sysparm_table_name') + '';


  var strQuery = "table="+table_name+"^active=true"


  var templates = new GlideRecord('sys_template');


  templates.addEncodedQuery(strQuery);


  templates.orderBy('name');



Cheers


View solution in original post

21 REPLIES 21

OK, that did not work


on this developer instance ServiceNow


username       admin


password         password



There is a UI Page called "apply_template_options" which has my original code and that is hard coded to the kb_knowledge table and shows me the 3 templates I have created for the Knowledge base


On the KB there is a button called "Apply Template"


I have added all three as bookmarks for that account



"apply_template_option_tweaked" has the modified code as outlined above and does not work too well.



I have a few more other things on the go, for for my immediate requirement I may just have to hard code that section and then work on the populating of the sliushbuckets afterwards.



If anyone wants to look and work out what I have managed to mangle it would be appreciated


Hi Julian,



I'm not sure why the jvar_templates vs. templates is not working that way... still playing with it.   However, in the beginning of your page try using this instead of the getWindowsProperties:



        <j2:set var="jvar_table_name" value="$[RP.getParameterValue('sysparm_table_name')]"/>




This part works at least.  




-Brian


This worked for me in the end



<g:evaluate jelly="true">


  var table_name = RP.getParameterValue('sysparm_table_name') + '';


  var strQuery = "table="+table_name+"^active=true"


  var templates = new GlideRecord('sys_template');


  templates.addEncodedQuery(strQuery);


  templates.orderBy('name');



Cheers


why have the jelly="true"?


You are correct, this script doesn't need it (jelly="true").   I had just copy/pasted his original code and made corrections to it.... but I didn't take it to task for efficiency.




-Brian