UI Script not working in new Service Portal

Katie A
Mega Guru

Hello, I am trying to create a very simple UI script such that I can write re-usable functions to call use with client scripts.

Global UI scripts

The simple UI script works fine on the CMS. However it DOES NOT work in the Service Portal.

Are UI Scripts no longer supported in the Service Portal? We are on Helsinki.

Catalog Client Script

UI Type: BOTH

function onLoad() {

    helloWorldTest();

}


UI Script

Global: TRUE

function helloWorldTest() {

  alert('Hello World');

}

1 ACCEPTED SOLUTION

nathanfirth
Tera Guru

b-rad That is incorrect, you can add UI Scripts to the Service Portal through the Theme. The theme has a related list of JS files, which if local is a reference to the UI Script table.



I would not recommend making the UI Scripts Global.


View solution in original post

9 REPLIES 9

Oh nice! I hadn't realized that. So instead of calling the ui script from the jelly you would call it as a js include.



Dependencies


Hi Nathan,


              What should be done to the Catalog Client scripts which are failing with the reason : 'Reference Error : SurfGlide_getField is not defined' ?


              SurfGlide_getField is a function which is part of GlideAjax SurfGlideAjaxUtils.


Bhavin Jain1
Mega Expert

Hi Nathan,

 

I have a weird issue while accessing the UI script from portal,

 

When I try to fetch the logged in user (eg: g_form.userID) through UI script in portal, It throws error which is fine.

But when i remove this condition and just console the simple log messages, it stills throws me error saying g_user is not defined.

The old version is still applied and does not refresh. 

I have added the UI script under themes.

Is there any way I can refresh the browser, this happens in portal UI script only.

 

Regards,

Bhavin

 

 

 

Bhavin,

You can force the use of the new UI Script version by updating the timestamp in the glide.lastplugin property. I also have posted an article describing how to create a Business Rule to keep this updated: How to Force Cache Update for UI Scripts.

Jeremy

 

Jeremy Box
Tera Contributor

There is a property that will allow you to force the cache update on the browser side called glide.lastplugin. Update it to a newer timestamp. I have posted an article with a workaround to keep it updated: How to Force a Cache Update for UI Scripts.