- 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-24-2020 07:41 AM
Weird. It's the same as
<?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 = jelly.sysparm_errors;
arr;
</g2:evaluate>
<j2:forEach var="jvar_error" items="$[jvar_errorlist]">
<h4> ERROR: $[jvar_error] </h4>
</j2:forEach>
</j:jelly>
UI Action method from which I'm calling..
function showRebuildError(errorList){
alert(errorList.length); // This prints 4
var gm = new GlideModal("x_gmi_build_error_dialog", false, 'modal-lg');
gm.setTitle("Your request cannot proceed. Please fix below errors!");
gm.setPreference('sysparm_errors', errorList);
gm.setWidth(600,300);
gm.render();
return false;
}
- 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-24-2020 08:17 AM
That works!!!!
Thanks a ton, Ankur.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-24-2020 08:23 AM
You are welcome
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader