2017年9月11日 星期一

[ServiceNow] Jelly script in UI Page

Just tried building a simple ui page in my developer instance (Istanbul).

I find that:

<g:...> and <j:...> tag do not work;
if the variable name in <g2:evaluate> does not start with "jvar_", the <j2:if > and <j2:while > cannot work properly;
<g2:breakpoint> prints nothing;


Ref: http://wiki.servicenow.com/index.php?title=Jelly_Tags#gsc.tab=0


<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">

<g2:evaluate var="jvar_gr_incident" jelly="true" object="true">
var gr = new GlideRecord('incident');
gr.orderByDesc('number');
gr.query();
gr;
</g2:evaluate>

<g2:evaluate var="jvar_a">
var a = 21;
a;
</g2:evaluate>

<g2:evaluate var="jvar_b">
var b = 21;
b;
</g2:evaluate>

<j2:set var="jvar_a" value="$[22]"/>
<j2:set var="jvar_b" value="$[2111]"/>

<div>

$[jvar_a] aa<br/>
<j2:if test="$[jvar_a!=21]">
   We did not find any active incidents. $[jvar_a]<br/>
</j2:if>
<j2:if test="$[jvar_a==21]">
   We found $[jvar_a] active incidents.<br/>
</j2:if>


abc $[jvar_a] vv</div>

<br/>
b= $[jvar_b]
<br/>

<table id="headerTable" >
<j2:while test="$[ jvar_gr_incident.next() ]">
<tr>
<td>
<a href="incident.do?sys_id=$[jvar_gr_incident.getValue('sys_id')]">$[jvar_gr_incident.getValue('number')] - $[jvar_gr_incident.getValue('short_description')]</a>
</td>
</tr>
</j2:while>
</table>

</j:jelly>

沒有留言:

張貼留言