Hide cross mark on UI page and show the page at the top

Harish74
Tera Expert

Hi there,

I created a UI page that displays Yes/No button. Based on the user input selection the actions gonna take place. But the user is still able to close the UI page using the "cross mark" without selecting any input. That should not happen. 

find_real_file.png

Please help me in removing that "cross mark" and also I want to place this UI popup at the top of page instead of center.

 

1 ACCEPTED SOLUTION

Hi,

You can use this code and it would show the confirm box with Yes/No and it comes in center

var dialog = new GlideModal('glide_modal_confirm', true, 300);
dialog.setTitle('Confirmation');
dialog.setPreference('body', 'Is there a Cost impact?');
dialog.setPreference('focusTrap', true);
dialog.setPreference('onPromptComplete', doComplete);
dialog.setPreference('onPromptCancel', doCancel);
dialog.render();
	
function doComplete() {
	callback(true);
}
	
function doCancel() {
	callback(false);
}

Output:

find_real_file.png

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

13 REPLIES 13

Hi,

Glad to know that my script worked.

It's an OOB and comes from platform level.

Please mark my response as correct and helpful and close the thread.

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hello @Ankur Bawiskar 

I have created a UI Page and if a user changes the state of sc_task to 'closed incomplete' then a custom popup will display with additional comment field mandatory. However, if the user clicks the (X) on the dialog box and saves, the record gets saved, which breaks the popup functionality.

I hope if we reload the form on click of (X) will solve this. Can you please suggest a way.

 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (isLoading || newValue === '') {
        return;
    }

    // Check if the state is changing to '4'
    if (newValue == '4') {
        var assignedTo = g_form.getValue('assigned_to');

        // Check if 'assigned_to' is empty
        if (!assignedTo) {
            // Display an error message
            g_form.addErrorMessage('Please fill in the "Assigned To" field before closing the task.');
            g_form.setValue('state', oldValue);
            return;
        }

        // If 'assigned_to' is not empty, proceed with the popup window
        var sysId = g_form.getUniqueValue();
        var dialogClass = GlideModal ? GlideModal : GlideDialogWindow;

        var dialog = new dialogClass('IC-Stop_Closure_Of_ScTask');
        dialog.setTitle(getMessage('Task Closure Reason'));
        dialog.setPreference('sysparm_sys_id', sysId);
        dialog.setPreference('sysparm_ok_button_name', getMessage('Ok'));
        dialog.on('closeCompleteSuccess', function () {
            dialog.destroy();
            gsftSubmit(null, g_form.getFormElement(), 'sysverb_update_and_stay');
        });
        dialog.render();
    }
}

 

Thanks 

@Vrushali11 

why to use UI page and not make the comments mandatory via UI policy?

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hello @Ankur Bawiskar 

You are absolutely correct, the customer requested a custom popup.  

Thanks & Regards 

Vrushali