The CreatorCon Call for Content is officially open! Get started here.

Confirmation with GlideDialogWindow Stuck on Loading

tiguin2798
Tera Guru

Hello Developers,

 

I am hoping someone can assist me as I am having some trouble with getting a confirmation box to appear using GlideDialogWindow. Granted I am new to javascript...I have attempted to piece together various parts of community posts and tutorial videos.

My goal here is to set a confirmation for change requests when the planned start date changes to a period we have deemed as blackout dates. There are a few conditions I need this script to follow.

State - New (we do not wish this to occur once approval has been requested)

Planned start date - a range of dates that may be updated later

User does not have role - xxxx_CAB_all_standard_read (a custom role all CAB members have)

When a user selects 'Proceed' it keeps the planned start date and saves the form to allow submission.

When a user selects 'Cancel' it clears the planned start date.

Below is my 'onChange' Client Script on the 'change_request' table.

 

function onChange() {
    if (!g_user.hasRole('xxxx_CAB_all_standard_read')) {
        var startDate = g_form.getValue('start_date');
        
        var parsedStartDate = new Date(startDate);
        
        var startRange = new Date('2024-10-01');
        var endRange = new Date('2024-10-31');
        
        if (parsedStartDate >= startRange && parsedStartDate <= endRange && g_form.getValue('state') === '-5') {
            var gdw = new GlideDialogWindow('are_you_sure_dialog');
            gdw.setTitle('Confirm Submission');
            gdw.setMessage('Change is being scheduled during the blackout period of October 1st-October 31st. Are you sure you wish to proceed?');

            gdw.addChoice('proceed', 'Proceed', true);
            gdw.addChoice('cancel', 'Cancel', false);
            
            gdw.on('choice', function(choice) {
                if (choice === 'Proceed') {
                    // Action for proceeding
                    g_form.save();
                } else if (choice === 'Cancel') {
                    // Action for canceling
                    g_form.clearValue('start_date');
                }
                // Close the dialog after a choice is made
                gdw.close();
            });
            
            gdw.render();

	} else
    // Optional: Handle the case where the user has the role
    g_form.addErrorMessage('Change has been scheduled during a blackout period.');
    }
}

 

I also created the below UI page that this script is calling. I'm not sure if anything needs to be passed here.

tiguin2798_0-1727121572864.png

 

 

The issue I'm having is as an 'itil' user that does NOT have the custom role, I am still receiving the error message when impersonating. Additionally, when selecting a date in that window it's as if the dialog box attempts to load, but gets stuck loading.

 

tiguin2798_1-1727121708472.png

 

 

Any advice on how to get this working is greatly appreciated!

 

 

0 REPLIES 0