- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2018 07:31 PM
Hello everyone, so I'm trying to increment a value by using a forEach jelly loop that's looping through 3 values in my array.
What I found out when trying to increment is that my forEach jelly loop is only running once?
The weird thing is my logs show it running once, but my info being displayed is as if it runs three times (information is being displayed correctly).
So I'm getting the correct information displayed, but the number I'm trying to increment to use later only increments once and not 2 more times.
I should note I'm working within a SCOPED app, not sure if that has anything to do with it.
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2018 08:59 PM
Hi Steven_S,
For me it's a little unclear what you're trying to accomplish here but with the example given here if you're looking for "running" to print out 3 times or the counter to increment then you'll need to synch the phases with the forEach loop. Currently, your forEach loop is running in phase 2 but the g:evaluates are in phase 1. So it should either print out 'running' and increment the counter value if those are also in phase 2.
For example,
<j2:forEach items="$[values] "var="jvar_upd">
<g2:evaluate>gs.info('running');</g2:evaluate>
<g2:evaluate>counter ++</g2:evaluate>
<p>$[jvar_upd]</p>
</j2:forEach>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2018 08:59 PM
Hi Steven_S,
For me it's a little unclear what you're trying to accomplish here but with the example given here if you're looking for "running" to print out 3 times or the counter to increment then you'll need to synch the phases with the forEach loop. Currently, your forEach loop is running in phase 2 but the g:evaluates are in phase 1. So it should either print out 'running' and increment the counter value if those are also in phase 2.
For example,
<j2:forEach items="$[values] "var="jvar_upd">
<g2:evaluate>gs.info('running');</g2:evaluate>
<g2:evaluate>counter ++</g2:evaluate>
<p>$[jvar_upd]</p>
</j2:forEach>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2018 09:03 PM
Hi Chris, thanks for the reply, sorry if I was unclear, the goal was to increment the "counter" with each loop.
Thanks Chris, I completely forgot about the phases and added that in my script now its incrementing correctly.
Thanks for your help!