Can anyone tell me how to have a Pop-Up message appear when creating an Incident or Request based on Group Assignments?

jeffbattaglino
Kilo Explorer

Can anyone tell me how to have a Pop-Up message appear when creating an Incident or Request based on Group Assignments?   I have a certain group of users that need to be handled differently than others, and I need to create a pop-up message that appears when one of these people is in the "Caller" field in a new ticket being entered.   Any assistance would be appreciated.

3 REPLIES 3

The SN Nerd
Giga Sage
Giga Sage

You have a few options for pop-up boxes. I personally consider pop-up boxes to be bad UI design unless you have a requirement to stop the user from doing anything until they have acknowledged something.



  • alert("Hello World"); Will pop up a window with "Hello World" and an 'OK' button.
  • confirm("Hello World"); Will pop up a window with "Hello World?" and a 'Ok' and 'Cancel' buttons.
  • g_form.showErrorBox("field_name", "Hello World"); Will put "Hello World" in an error message below the specified field.
  • g_form.hideErrorBox("field_name"); Will hide an error box that is visible under the specified field.
  • g_form.addInfoMessage("Hello"); Will show an info message on the top banner


Scripting Alert, Info, and Error Messages - ServiceNow Wiki



In theory you could create a onChange client script on the caller field as follows



function onChange(control, oldValue, newValue, isLoading) {


if (g_user.hasRole('special_person')) {


var groupName = g_form.getValue('assignment_group');


if (groupName = "750e0d304f524200742d4a318110c767") { //sys_id of assignment group


        alert('Message');


}


}


}



It is recommended not to have sys_id's in client scripts as it makes code difficult to read but this should give you an idea.



ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022

Hi Paul,

 

I have a similar kind of requirement.

 

When User clicks Cancel Button in Incident form. It should give a Popup similar to "confirm" popup box.

 

Can you please give me a sample code on how this requirement can be achieved? If you don't mind.

 

Regards,

Sailesh J

bernyalvarado
Mega Sage

Hi Jeffrey, to add what Paul has shared I will strong advice you use the g_form.addInfoMessage instead of using any type of popup.



Thanks,


Berny