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

Goran WitchDoc
ServiceNow Employee
ServiceNow Employee

Its the darn phases..



As you can see on the wokring example you have j2 = phase 2 and the you use [] are values. like$[RP....



first example is in phase 1... as you have g:.. Then you use {} around values... like ${RP....



So try change it from



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



to:


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


poyntzj
Kilo Sage

I'll give this a go when I get back to this particular routine


Still struggling


I have progressed.   I copied sections from a good working ui page and simply changed the variable name.


all it needs to do is to take the name of the table I am passing to it and then query a glide record and in a drop down list display the returned data.



my ui action has


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



my ui page has


<?xml version="1.0" encoding="utf-8" ?>


<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">



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


<input type="hidden" name="table_name" value="$[jvar_table_name]"/>


test $[jvar_table_name]



and this loads and shows that that table name has passed


now a little later and based on the other ui page, the following should work


<g:evaluate>


var templates = new GlideRecord('sys_template');


templates.addQuery('table',jelly.jvar.table_name);


templates.orderBy('name');


templates.query();


</g:evaluate>


<j:while test="${templates._next()}">


<option value="${templates.sys_id}">${templates.name}</option>


</j:while>


but it does not


I thought OK, change the jelly.jvar_table_name to $[jvar_table_name] and it still does not query


physically changing the query to have a hard coded name works OK - 'change_request' is fine.



Nope, Jelly is not my strongest point.


In the evaluate.. If you want to just jelly variables inside a evaluate you need to have jelly="true".



Like this: <g:evaluate jelly="true">



That The first thing I noticed. I'm a bit busy, but if it still ain't working just write here and I'll look into it in a hour or two