Sweet Alert 2 - use with catalog client scripts
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-06-2022 08:20 AM
Hi all,
I installed this update set for Sweet Alert2 into by dev instance. I would like to use Sweet Alert2 for generating some alerts on catalog items using catalog client scripts. I tested with a catalog item and it partially works in service catalog view, but does not work at all in service portal view. In service catalog view I say it partially works because the alert loads, but the confirm button and cancel button do not show as coded... However the script with Sweet Alert 2 does not working at all (no alert shows at all) in service portal view -- a "swal is not defined" error shows in browser console. Below is the code snipped I am using in a catalog client script. Can someone tell me if I am using it totally wrong :)? Has anyone else gotten Sweet Alert 2 working with catalog client scripts? Below is the code I am trying out.
function onLoad() {
loadMe();
function loadMe() {
//Type appropriate comment here, and begin script below
swal({
title: 'Please read terms!',
text: 'Do you understand the terms?',
icon: 'info',
showCancelButton: true,
confirmButtonText: 'Yes, I understand the terms!'
});
}
}
And also attaching screenshots showing it partly working in catalog view and screenshot with error I see when I view the catalog item with script in service portal view.
TIA,
Chris
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-14-2022 09:48 AM - edited ‎11-14-2022 09:48 AM
Hi. It's because your portal doesn't know which JS Includes to use. You need to add the script includes you added to get sweetalears to work, to the themes of your portal so they can be called/used
Go to Service Portal - Portals
Find your portal and open it
Open the Theme record you have associated to this portal
At the bottom go to the "JS Includes" and click "edit"
Search for and add the sweetalerts Script includes (search for *sweet)
Save
Try your catalog item again on the portal.
-----please mark this answer as solved if applicable. It helps the community when you do----
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-21-2023 02:18 AM
I faced the same issue and your comment helped, thank you so much 🙂