Get a first look at what's coming. The Developer Passport Australia Release Preview kicks off March 12. Dive in! 

How to call JS library in UI page

Abhijit Das7
Tera Expert

Hi Everyone,

 

I want to call external JS library in UI page. How can I call below JS library ?

 

JS library - "https://cdn.jsdelivr.net/npm/jsframe.js/lib/jsframe.min.js".

 

Thanks

 

1 ACCEPTED SOLUTION

Not applicable

Hi @Abhijit Das7 ,

You need to store JS library in UI scripts. Then call it from UI Scripts.

Sample :

var UI=document.createElement('script');
UI.src="file_name.js";
document.body.appendChild(UI);

Please refer to the blog : https://john-james-andersen.com/blog/service-now/linking-several-javascript-libraries-servicenow-ui-...

 

View solution in original post

3 REPLIES 3

Not applicable

Hi @Abhijit Das7 ,

You need to store JS library in UI scripts. Then call it from UI Scripts.

Sample :

var UI=document.createElement('script');
UI.src="file_name.js";
document.body.appendChild(UI);

Please refer to the blog : https://john-james-andersen.com/blog/service-now/linking-several-javascript-libraries-servicenow-ui-...

 

Hi @Community Alums 

 

UI Script :

bb11.png

 

UI Page:

HTML

 

<!-- <?xml version="1.0" encoding="utf-8" ?> -->
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide">

	<div style = "width:600px; height: 450px; border: 1px solid">
	<!--<script src="https://cdn.jsdelivr.net/npm/jsframe.js/lib/jsframe.min.js"></script>-->

	<g:requires name="global.myUIscript.jsdbx" />

	<input type="button"  style= "background: blue; color: white ; border-radius: 1px; padding: 10px 22px; font-size: 16px; font: Sans-serif" value="OPEN" onclick="openepgp()"/>	
	      
		</div>			
</j:jelly>

 

CLIENT SCRIPT

 

function openepgp() {
   
    var jsFrame = new JSFrame();
    var frame01 = jsFrame.create({
        title: 'Window1',
        left: 20,
        top: 20,
        width: 320,
        height: 160,
        url: 'www.google.com', //URL to display in iframe
        //urlLoaded:Callback function called after loading iframe
        //urlLoaded: (frame) => {
        //Called when the url finishes loading
        //}
    });
    frame01.show();

}

 

 

We want to use JS Frame to resize pop up.

 

Thanks .

Not applicable

Hi @Abhijit Das7 ,

Now, it's a different ask @Abhijit Das7 . i think your original question was for on calling the JS libraries and now what you are asking is a use case. Please raise another question in the community and close this thread.