How do you load a js library for widgets?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
â01-28-2020 08:21 AM
Trying to import a js library to use with a widget on the service portal, what is the best way to import the library and reference it within the html. I've tried "<script src=.." but it doesn't seem to work
- Labels:
-
Service Portal Development

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
â01-29-2020 01:08 PM
Are you getting any errors in the console?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
â01-29-2020 01:30 PM
well it appears that its stopping at "Initialization finished. Ready to start", which makes me assume that it's not able to access the quagga functions from the dependency

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
â01-29-2020 01:52 PM
Right, I would thing you need to instantiate your Quagga class at some point before using it. Try replacing the line where you set your const, but use var:
var Quagga = require('quagga').default;
Log what that returns and see if that helps.
P.S. There's a barcode widget that comes OOB that you may be able to reference, it's called "Barcode"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
â01-29-2020 01:59 PM
Makes sense, and I attempted to use that widget but it didnt seem to work on the service portal.
This is the error that I am recieving after adding that line:
Uncaught ReferenceError: require is not defined
at HTMLInputElement.eval (eval at globalEval (js_includes_sp_libs.jsx?v=12-03-2019_1915&lp=Tue_Jan_21_06_25_19_PST_2020&c=35_683:185), <anonymous>:97:22)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
â01-29-2020 02:04 PM
seems like require()
does not exist in the browser/client-side JavaScript