- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-23-2020 10:11 PM
I have an array of errors I received from UI action and trying to print it on a UI page. But Instead of running through whole Array jelly prints all values as a string.
<?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_errorlist" object="true" jelly = 'true'>
jelly.sysparm_errors;
</g2:evaluate>
<j2:forEach var="jvar_error" items="$[jvar_errorlist]">
<h4> ERROR: $[jvar_error] </h4>
</j2:forEach>
</j:jelly>
If there is an array like ['This is error 1', 'This is error 2', 'This is error 3', 'This is error 4']. I want it to be like
ERROR: This is error 1
ERROR: This is error 2
ERROR: This is error 3
ERROR: This is error 4
Can someone explain what I'm doing wrong here. I tried many different ways but I can't get it working.
Solved! Go to Solution.
- Labels:
-
Now Experience UI Framework
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-24-2020 08:09 AM
Hi,
So you are sending the value from UI action
please update as below
<?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_errors" value="$[RP.getWindowProperties().get('sysparm_errors')]"/>
<g2:evaluate var="jvar_errorlist" object="true" jelly="true">
var arr = jelly.jvar_errors;
arr = arr.toString().split(',');
arr;
</g2:evaluate>
<j2:forEach var="jvar_error" items="$[jvar_errorlist]">
<h4> ERROR: $[jvar_error] </h4>
</j2:forEach>
</j:jelly>
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-23-2020 10:17 PM
Hi,
this should print
<?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_errorlist" object="true" jelly = 'true'>
var arr = ['This is error 1','This is error 2','This is error 3','This is error 4'];
arr;
</g2:evaluate>
<j2:forEach var="jvar_error" items="$[jvar_errorlist]">
<h4> ERROR: $[jvar_error] </h4>
</j2:forEach>
</j:jelly>
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-24-2020 07:12 AM
Hi Ankur,
That didn't work. It's still printing 'This is error 1,This is error 2',This is error 3,This is error 4'..
Also, I'm getting this array from UI Action parameters so I have to use
var arr = jelly.sysparm_errors
arr;
Am I right?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-24-2020 07:21 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-24-2020 07:23 AM
Hi,
please share your script
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader