- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2016 12:15 PM
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
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2016 02:10 PM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-10-2016 10:45 AM
A quick redo.. Since I don't see the whole code... any reason for the first part...
This would work
<g:evaluate object="true">
var templates = new glideRecord('sys_template');
var myTable = RP.getWindowProperties().get('sysparm_table_name');
templates.addQuery('table', myTable);
templates.orderBy('name');
templates.query();
</g:evaluate>
Then the rest of your code
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2016 12:02 AM
Still not getting there
Ui page and UI action attached - the ui page is taken from the sncguru and works - just me trying to make this drop down universal
The UI Action is on the kb_knowledge table and will add a new button to the knowledge article called "Template"
The UI Page is called "apply_template_options"
changing line 23 to a manual option works so I know it is there
the line asdf + $[jvar_table_name]
is just there for me to see that the value is being passed correctly.
Cheers
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2016 12:23 AM
Well,
One thing I saw direct is that you use Phase 2 here: <j2:set var="jvar_table_name" value="$[RP.getWindowProperties().get('sysparm_table_name')]"/>
then your g:evaluate is in Phase 1, which mean it have no clue about variables in phase 2.
g:evaluate jelly="true">
var templates = new GlideRecord('sys_template');
templates.addQuery('table',jelly.jvar.table_name);
templates.orderBy('name');
templates.query();
</g:evaluate>
I would replace the code above with this:
<g:evaluate object="true">
var templates = new glideRecord('sys_template');
var myTable = RP.getWindowProperties().get('sysparm_table_name');
templates.addQuery('table', myTable);
templates.orderBy('name');
templates.query();
</g:evaluate>
And then you also don't need the j2 so remove that: <j2:set var="jvar_table_name" value="$[RP.getWindowProperties().get('sysparm_table_name')]"/>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-10-2016 12:37 PM
Another thing about jelly and its phases. Since in your example above you do the set with j2, that means it's in phase 2, and then you can't use those variables in phase one.. that the evaluate is in.. Hope I'm not confusing you with all my posts here now.. Just shout and I'll try to help you if you don't get it right, jelly can be a pain...
//Göran

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2016 12:38 AM
Hi Julian,
In your "<g:evaluate...>" tag, the addQuery() statement incorrectly references your variable as:
"jelly.jvar.table_name".
It should be:
"jelly.jvar_table_name"
See if that makes the difference.
-Brian