How can I add external javascript library to any UI page?

Jeet
Tera Expert

Hi Team,

I have created an UI page and I want to add javascript library to my html code how can I do. I want to add this lib https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.3.2/jspdf.debug.js

I went thru this link (UI Scripts - ServiceNow Wiki) but Its giving me an error "Uncaught invalid module definition, module id must be defined and be a string"

Otherwise please let me know for this structure   <script>https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.3.2/jspdf.debug.js "></script>   how can I embed this, Is it possible in ServiceNow   <script>https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.3.2/jspdf.debug.js "></script>

UI page code -

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

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

<html>

<head>

  <script></script> // ADDED UI SCRIPT

  </head>

  <body>

  <div id="content">

        <h3>Hello, this is a H3 tag</h3>

      <p>a pararaph jjfsafoidaf</p>

</div>

<div id="editor"></div>

<button id="cmd">generate PDF</button>

  </body>

  </html>

</j:jelly>

NOTE- If there is another way to achieve this please let me know guys. TIA

Thanks,

Jeet

2 REPLIES 2

Madhava_Kumar
Mega Guru

Hi Jitendra Ji,



Your UI page code looks correct for me.


For more information goto the below link.



Jenkins dev - JavaScript in .jelly files



Thanks


Madhava


Mahi9
Tera Contributor

Hi ,



I used many lib, but i didn't find find any error. below is my UI page for Generate PDF.




find_real_file.png