GlideModal not working, getting console error
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-05-2023 12:17 AM
Hi everyone,
I need a pop it must have only "OK" button.
So i am using OOB model box code, while using that i getting Error - There is a JavaScript error in your browser console . I checked in console - ReferenceError: GlideModal is not defined. How do i use this model. Can any one assist me
Here is the java script which i have used
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-05-2023 12:48 AM
Hello @Suresh K3 ,
To use `GlideModal` in ServiceNow, you need to ensure that the `GlideModal` script include is loaded. Here's an updated code snippet and step-by-step guidance to implement the pop-up using `GlideModal`:
1. Load GlideModal Script Include: Confirm that the `GlideModal` script include is loaded in your instance. To do this, navigate to "System Definition" > "Script Includes" in the application navigator. Search for `GlideModal` and ensure it exists. If it doesn't exist, create a new script include with the name `GlideModal` and the following script content:
var GlideModal = Class.create(GlideWindow, {
initialize: function (title, readOnly, width, height) {
GlideWindow.prototype.initialize.call(this, 'dialog_form', readOnly, width, height);
this.setTitle(title);
this.setClassName('glide_modal');
this.setBody(TEMPLATE);
this.setFooter(FOOTER);
}
});
2. Update the JavaScript Code: Replace your existing JavaScript code with the following updated code:
if (g_scratchpad._action_confirmed) {
return true;
}
var dialog = new GlideModal('Confirmation', false, 300);
dialog.setPreference('body', "Are you sure to save?");
dialog.setPreference('focusTrap', true);
dialog.setPreference('onPromptComplete', doComplete);
dialog.setPreference('onPromptCancel', doCancel);
dialog.render();
return false;
In this code, we directly create an instance of `GlideModal` without using the `'glide_modal_confirm'` template. The title is set directly as `'Confirmation'`, and the body message is set as a string.
3. Define the `doComplete` and `doCancel` Functions: Implement the `doComplete` and `doCancel` functions according to your requirements. These functions will be called when the user clicks the OK or Cancel buttons in the pop-up.
4. Test the Implementation: Save the updated code and test the functionality. The pop-up should appear with the "OK" button, and the `doComplete` and `doCancel` functions should be triggered accordingly.
Make sure to clear any browser cache or reload the ServiceNow instance to ensure the updated script includes and code changes are applied.
Note: If you continue to encounter the `ReferenceError: GlideModal is not defined` error after following these steps, ensure that the `GlideModal` script include is correctly loaded and accessible in your instance.
If this helped you in any way, please hit the like button/mark it helpful. So it will help others to get the correct solution.
regards,
Prasad
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-05-2023 01:04 PM
I have been trying to figure out this GlideModal issue in my PDI (Utah).
I was getting this error in the system log:
com.glide.script.RhinoEcmaError: "GlideModal" is not defined.
sys_ui_action.1f36aab047f321108f89fa8bd36d43e9.script : Line(3) column(0)
1: gs.info("In signature UI Action starting");
2:
==> 3: gDialog = new GlideModal('accept_signature');
4: gDialog.setTitle('Signature Pad');
5: gDialog.setWidth(500);
6: var rec_sys_id = g_form.getUniqueValue();
After following your step 1 I got:
com.glide.script.RhinoEcmaError: undefined is not a function.
sys_ui_action.1f36aab047f321108f89fa8bd36d43e9.script : Line(3) column(0)
1: gs.info("In signature UI Action starting");
2:
==> 3: gDialog = new GlideModal('glide_confirm_basic');
4: //gDialog = new GlideModal('accept_signature');
5: gDialog.setTitle('Signature Pad');
6: gDialog.setWidth(500);
And this:
com.glide.script.RhinoEcmaError: "GlideWindow" is not defined.
sys_script_include.d98198ae477321108f89fa8bd36d43c4.script : Line(1) column(0)
==> 1: var GlideModal = Class.create(GlideWindow, {
2: initialize: function (title, readOnly, width, height) {
3: GlideWindow.prototype.initialize.call(this, 'dialog_form', readOnly, width, height);
4: this.setTitle(title);
GlideWindow is not in the system definition -> script includes either.
I looked in the production instance (Tokyo) I work with and neither GlideModal nor GlideWindow are in the system definition -> script includes there.
Why are these instances missing these functions? Are they not out of the box scripts?
Should I open a HI ticket?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-05-2023 10:50 PM
Hi @Steve Stivers1 ,
Please consider opening a High Impact (HI) ticket with ServiceNow support to seek assistance from their technical experts. They can provide guidance and investigate any potential issues or misconfigurations in your instance.
-Prasad
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-13-2023 11:24 PM
I don't know if you've solved your issue, but it looks like you have the GlideModal code setup in a server-side UI Action. GlideModal is a client-side class, so you need to set the UI Action to be able to run in the browser: