- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-23-2017 03:08 AM
Hi
I have written a code for onchange client script,
I want to populate different options for topic when differrent options are selected from category.
Every thing is working fine, its showing all the values correct, but after few seconds
for eg i have selected benefits in category and fastly i am selecting topic than its not showing any option, but when i have selected category and after 2-3 secs if i am selecting topic than i can see all the option,
So i believe this is some performance issue that my code is taking more time to populate option in topic field, you can see in below screenshots, first no options are coming , in second all option are coming when i selected topic after 2-3 secs
Below is the code which i have written for this
I am getting a list from my table, using script include, than populating through add option function
now here '--None--' option is coming as soon as i am changing category value which is not in for loop, so i believe for loop is taking a bit of time to perform action
What should i do here, so that my code run fast.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-23-2017 04:35 AM
Hi Anshul,
If you want to use the script include, use getXMLWait() instead of getXML().
getXML() is asynchronous so the function 'DoSomething()' runs after you get data from ServiceNow. Getting data takes 2-3 seconds.
http://wiki.servicenow.com/index.php?title=GlideAjax#Synchronous_Glide_Ajax

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-23-2017 11:11 PM
I am not aware of any other way, but don't you think using getXMLWait() may kill your web page if there is delay in data loading, that more the delay the more the user session will be locked until the response is received. I think 1 to 3 sec should still be ok with getXML() function. what's your thought?
I am not an expert, we can get others opinion as well.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-23-2017 11:14 PM
Yeah i know, but this is the first time i am facing issue with getXMl(), so thinking of using getXMLWait().
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-23-2017 11:15 PM
This is exactly what I mentioned in previous comments when Anshul wants to go with getXmlWait(). The reason you are looking for better code but in that process,getxmlwait will degrade the performances.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-24-2017 02:40 AM
i found some information , since i am working in scoped application that is the reason i am not able to get any output while using getXMLWait.
getXMLWait not works in scoped application it only works in global appication, now i need to find that how can i pause my form for 3 secs when any value is selected from category.
can i use setTimeout(function()) here.
Now what i want is when i select any category than my form should get hang for 3 secs, and after that only i should able to choose topic.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-24-2017 02:43 AM
Yes you can use setTimeout(function()) in client side. On server side you can use gs.sleep() if required.
can I use the SetTimeout() function within a business rule, or something equivalent?