How to create For loop in Jelly when returning multiple values from GlideAjax?

bbf3562
Kilo Guru

I am building UI macro and I am new to Jelly language. I am trying to figure out how to set up For loop in <script> tag because I got return of multiple values(Group Members) using JSON from GlideAjax Script Include. I need a loop to separate values to make a list in table HTML. Do I need to use Jelly foreach tag or I can use javascript For loop? If so then is my code are correct using "answer" variable in foreach loop as array? Here is my script,

find_real_file.png

find_real_file.png

1 ACCEPTED SOLUTION

Gurpreet07
Mega Sage

Try this


for(var count = 0; count &lt; answer.length; count++)


View solution in original post

3 REPLIES 3

danpatino
Tera Expert

Hi Bradley,



I think your confusion comes from trying to use Jelly (server-side processing at page load) with GlideAjax (initiated client-side).



From your snippet, it looks like you are trying to lookup some group data when a form is populated (I'm guessing catalog form) to create a custom table.   I would just forget about Jelly altogether since everything will occur after the page is loaded.   Just use a regular for loop to iterate through your results.



Also, using jQuery might help you out a bit.   As long as you use the work 'jQuery' in place of the dollar sign ($), you should be okay.


Is using for(var count = 0; count &amp;lt; answer.length; count++) suppose to work because I assume &amp;lt; mean <=? I tried that way and nothing happen.


Gurpreet07
Mega Sage

Try this


for(var count = 0; count &lt; answer.length; count++)