How to display alerts on the screen with UI Script and ClientScript

KS18
Giga Guru

I would like to have an on-screen alert for a specific group when an incident is created.
I want to call the UI Script from OnSubmit's ClientScript, but it does not work.

find_real_file.png

 

 

find_real_file.png

 

1 ACCEPTED SOLUTION

Hitoshi Ozawa
Giga Sage
Giga Sage

Hi KS,

UI Script from Client Script is not supported in Service Portal. Select UI Type = "Desktop" and check "Global".

find_real_file.png

Then, the function can be called from Client Script.

function onSubmit() {
  showPopup();
}

View solution in original post

4 REPLIES 4

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

check this out

Call UI Script From Client Script | Practical Demonstration

Regards
Ankur

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

Harshal Gawali
Giga Guru

Hi,

You can directly call with function name in client script.

function onSubmit(){

       showPopup();

}

 

Regards,

Harshal.

Hitoshi Ozawa
Giga Sage
Giga Sage

Hi KS,

UI Script from Client Script is not supported in Service Portal. Select UI Type = "Desktop" and check "Global".

find_real_file.png

Then, the function can be called from Client Script.

function onSubmit() {
  showPopup();
}

Hitoshi Ozawa
Giga Sage
Giga Sage

@KS FYI, using GlideRecord in client script is not really recommended too much but if it's just to display an alert onSubmit, GlideRecord may be used in Client Script like below. This works both in Service Portal and UI.

function onSubmit() {
    var groupName = 'ITIGROUP';
    var gr = new GlideRecord('sys_user_grmember');
    gr.addQuery('user', g_user.userID);
    gr.addQuery('group.name', groupName);
    gr.query(function(gr) {
        if (gr.hasNext()) {
            alert('Incident is Created');
        }
    });
}