How to get current form values in UI macro jelly script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2018 03:05 AM
Hi All,
I have created a formatter and UI macro. And formatter is added to incident form. Now i want to display current incident fields to the formatter.
Created UI macro with below script but it is not showing any values. Please help me.
<?xml version = "1.0" encoding = "utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<g:evaluate object="true" var="jvar_gr">
var sys_id = current.getValue('sys_id');
var gr = new GlideRecord("incident");
gr.addQuery('sys_id', sys_id);
gr.query();
gr;
</g:evaluate>
<j:if test="${jvar_gr.next()}">
<j:set var="jvar_phase2" value= "${gr.number} "/>
<j:set var="jvar_phase2" value= "${gr.priority} "/>
<j:set var="jvar_phase2" value= "${gr.impact} "/>
<j:set var="jvar_phase2" value= "${gr.state} "/>
</j:if>
</j:jelly>
TIA
Madhuri
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2018 03:17 AM
Hi
PFB the link :-
Hope this helps you.
Mark Correct if it helps.
Warm Regards,
Omkar Mone
www.dxsherpa.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2018 03:37 AM
Hi Omkar,
Thanks for the reply. But i have to use multiple <g2 evaluates for each variable ?? Can't be possible to display all fields in single g2 tag?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2018 03:19 AM
Hello,
I believe you should use g_form.getUniqueValue() instead of current.getValue().
If the UI Macro runs on the client.
With regards
Anton
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2018 04:41 AM
When using a UI macro on the form via a formatter you only have access to current in phase2 of the jelly script.
Meaning, this doesn't work:
${current.getValue('number')}
but this does:
$[current.getValue('number')]
So for your script i think you can simplify it to something like this (which will display number, priority, impact and state on the form):
<?xml version = "1.0" encoding = "utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
Number: $[current.getValue('number')]<br/>
Priority: $[current.getValue('priority')]<br/>
Impact: $[current.getValue('impact')]<br/>
State: $[current.getValue('state')]<br/>
</j:jelly>