Javascript - change text automatically every 10 secodns

Pastupe
Mega Guru

Hi,
I need help please. Im beginner in javascript and I learn everething from beginning.

I created UI page.
Result is that UI page display several records each to other (kb query - gliderecord ).
I would like to display every record separately one by one changing every 10 seconds.
See example on screen that now they display all one behind another ....
Is there any change to use javascript to show my variable 1 per 10 seconds which I call $[jvar_inc_link] ?

I would like to learn this how to create code to show results from $[jvar_inc_link] every 10 seconds ..

thanks to all
Petr

23 REPLIES 23

Konstantin It work now. Great!!!
I forgot to make sure if UI script is global. Not it is global and it work perfect.

Thanks lot, you learned me a lot now.
I have now only second issue, use this whole code but I need put in it some New Array where I put results from Glide Record of KB records.


Have you any idea how to use $[inc.short_description] in this code instead of using this numbers "10000" ?
Shall I somehow move result from GldieRecord --- $[inc.short_description] --- to new Array and then somehow place it in code ?

Please give me some help on this also.

Very appreciate you helped me with a first part to use JQuery - big THX!!!.
Petr


Hello,

you have to query GlideRecord in Jelly (), iterate through an array of records () and print out html-code

For reference:
- http://wiki.servicenow.com/index.php?title=Extensions_to_Jelly_Syntax
- http://wiki.servicenow.com/index.php?title=Jelly_Tags


Hit the Thumb Icon and/or mark as Correct, if my answer was correct. So you help others to see correct responses and I get fame 🙂

Cheers,
Kostya

Query i have already done., but how to please it in array ? Im creating arry first time.
Must i move somehow in to array sys_id of below query ?


<?xml version="1.0" encoding="utf-8">



var inc = new GlideRecord('kb_knowledge');
inc.addActiveQuery();
inc.addQuery('display_attachments','true');
inc.addQuery('topic','General');
inc.query();


You have the sys_id in the variable ${inc}. Just iterate like here shown: http://wiki.servicenow.com/index.php?title=Jelly_Tags#while
F.e.



<g:evaluate var="jvar_gr" object="true">
var gr = new GlideRecord('kb_knowledge');
gr.addActiveQuery();
gr.addQuery('display_attachments','true');
gr.addQuery('topic','General');
gr.query();
</g:evaluate>

<j:while test="${jvar_gr.next()}">
<a href="kb_knowledge.do?sys_id=${jvar_gr.getValue('sys_id')}">${jvar_gr.getValue('short_description')}</a>
</j:while>


// did not tested 🙂


Hit the Thumb Icon and/or mark as Correct, if my answer was correct. So you help others to see correct responses and I get fame 🙂

Cheers,
Kostya

I completed my code, attached file.
But it show always every 5 seconds one same result from query even there exist 5 results from query.

do I need somehow to move this $[inc.short_description] somewhere in variable ?

Thanks
Petr