Can I remove "OnChange" isLoading? what is for?

guille
Kilo Expert

Hi,

I'm fixing some ACE report codes, most of them the used wrong the getReference method without a callback function... I've noticed that on service now wiki they use in this way(they removed the isLoading condition):

find_real_file.png

I've been using this on my scripts to fix the ace report bad practice issue, however I would like to know if keeping the following statement will affect the script, does this do any change?

if (isLoading){

              return;

      }

1 ACCEPTED SOLUTION

randrews
Tera Guru

you absolutly can remove that and the if newvalue == ''   line depending on what the code is doing/for...



the onloading section prevents the code from running just because the page loaded <technically the value DID change on load>


the newvalue test stops the code if the value is blanked out...



again examine what you WANT the code to do.. if it SHOULD run on load before they have a chance to touch the value take it out... however normally it is best to leave that in so the page loads quicker.. same with the new value test.. if a blank value requires an action remove it.


View solution in original post

7 REPLIES 7

Rama Chandra D
Kilo Guru

Hi Guille,



The lines of code are to ensure that no script runs when the page or form is loading.This is to ensure faster loading time. Please check section 9.2 at


http://wiki.servicenow.com/index.php?title=Client_Script_Best_Practices#Add_the_isLoading_Check_.28o...


So if It won't affect the get Reference call? I just wanted to double check at the image above Servicenow removes it. so If I add it again it wont lift an ACE report flag?


If you have no specific code that you need to run when the form loads, removing it shouldn't matter.



Regards


Darshak


randrews
Tera Guru

you absolutly can remove that and the if newvalue == ''   line depending on what the code is doing/for...



the onloading section prevents the code from running just because the page loaded <technically the value DID change on load>


the newvalue test stops the code if the value is blanked out...



again examine what you WANT the code to do.. if it SHOULD run on load before they have a chance to touch the value take it out... however normally it is best to leave that in so the page loads quicker.. same with the new value test.. if a blank value requires an action remove it.