How long does it take for a UI script change to take effect?

cdgaefke
Kilo Expert

I have a non global UI script that is referenced in a UI Macro by a formatter (maybe it's the other way around) so that I can reference all the routines on my modules without the UI script being global.

 

I'm experiencing very odd timing problems.

 

I'll make a change in my UI script, reload the module, but the changes don't seem to be taking immediate effect.   And I'm not sure exactly how/when to get them to take effect.

 

I typically run with three browsers open:

 

Firefox is my main coding browser.

IE11 is used for my reference, IE, to see something else in SVN while coding in Firefox

Chrome I use for testing functionality

 

Up until now this setup was working fine for me.   I'd make a change in Firefox, save it, reload the module in Chrome and see the changes.

 

Now, however, I'm using the setup above, where a UI script is in a UI Macro that is in a formatter.   And I never know when my code is going to take affect.   I've tried reloading the module, logging out, closing browsers and relogging, pressing Ctrl-F5 to force a refresh, and I'm getting inconsistent results.   Sometimes my code is active, sometimes it isn't.   If I check the code, the changes are there in all the browsers, but it seems as if SVN is using an older version somewhere.   Right now I have a simple alert() in the beginning of my routine, and IE won't show it, but Firefox will.   And my most recent change isn't showing anywhere!

 

Last time this happened I thought I was running into browser compatibility issues, and I went home for the day slightly distressed that I have code that works in one browser and not another.   The next day, without making any changes, it suddenly worked in both browsers!   Now I understand it's the same timing issue I'm seeing now.

 

Any thoughts on this oddness?   It's making coding very difficult, as I never know if I have a typo somewhere or if my code just hasn't taken effect yet.

 

Thanks.

1 ACCEPTED SOLUTION

cdgaefke
Kilo Expert

I ended up opening a ticket on   HI about this.   The devs gave me this code to put in the UI Macro which works beautifully:



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


<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">


          <g2:evaluate var="jvar_stamp">


                  var gr = new GlideRecord('sys_ui_script');


                  gr.orderByDesc('sys_updated_on');


                  gr.query();


                  gr.next();


                  gr.getValue('sys_updated_on');


          </g2:evaluate>


          <g:requires name="YOUR SCRIPT NAME HERE.jsdbx" params="cache=$[jvar_stamp]" />


</j:jelly>


View solution in original post

16 REPLIES 16

marcelo_moreli
Mega Guru

Have you tried cleaning the server's cache? (Type cache.do on the smart filter)



Thanks,


Thanks, I wasn't aware of that option.   I entered cache.do, and it didn't do anything.   It was about 45 minutes after I wrote the above, and nothing had changed.   IE was behaving differently than Firefox, as Firefox saw a more recent code change, but still not the most recent.   IE was at least two revisions behind.



Since my sessions had timed out on both browsers, I was forced to log back in.   No change.



I closed Firefox completely, and now it appears to be using the right version of the code.


IE no change, it's at least two versions behind.


Chrome I didn't have open.   I just opened it, and it's behaving like IE, at least two revisions behind.



Any more ideas?


Some time ago I was developing UI Scripts and had similar problem.



What I've done: Inspected the Page to see the source code, and the script I was changing, example: "<script></script>". This way I could open a new tab o the browser with instance.service-now.com/scripts/classes/RequestManager.jsx



In this new Tab, I used to refresh it using F5, so it shows the new code (and after it shows the new code, the page was executed correctly).


Mark Laucus
Giga Guru

Changes to UI Scripts are immediate.   Any changes should be testable.   One item to look is maybe how the script is being cached in IE.   Look at the article below (almost at the bottom of the article) to set caching with IE and ServiceNow.



Troubleshooting Performance - ServiceNow Wiki