Service Portal UI Script

Ken83
Mega Guru

Hello Community,

        I've seen this question asked before and i've seen a few others similar to it. I'm trying to configure a UI Script in my Service Portal and i'm not having any luck getting it to behave as expected. I have gone into the Theme for my Portal and added a JS Include, selected my UI Script. When I call the method from the UI Script in an onLoad Client Script, nothing happens and the following message is logged to my browser console → js_includes_sp.jsx?v=05-19-2017_1034&lp=Thu_Jun_08_10_56_47_PDT_2017&c=19_473:63723 (g_env) [SCRIPT:EXEC] Error while running Client Script "Format Work Number(Default UI)": ReferenceError: helloWorld is not defined â†� It may be worth noting that in the default UI, I get the expected result but in the Service Portal, I do not.

This is the article I was referencing →UI Script not working in new Service Portal and I noticed b-rad mention that UI Scripts may not be supported in the Service Portal. So i'm a little confused on the direction to go here. Here is the code in my UI Script which is marked active and global...

function helloWorld(){

alert("THIS IS FROM THE UI SCRIPT");

}

Any suggestions here? Am I missing something?

11 REPLIES 11

Hi 

Were you able to resolve the second question? We are facing the same issue. we are getting class not defined error when we use Ui Script in Portal.

 

Any helps are appreciated.

 


Regards.

raprohaska
Kilo Guru

I have followed these steps and it is true that the script is available for each page BUT if there is code to execute automatically on page load, it will only run on initial load of the file. Since the script is cached until a full page refresh is performed, navigating from page to page within the portal doesn't trigger that code again.

Is there a way to force the file to unload once the onload script is complete?