VIP User Popup

inzomniak
Kilo Explorer

We are a relatively new user of ServiceNow which has recently gone live as part of our managed services contract and a function that I have been asked to look into is to have a java popup triggered from the user ID field for some of our VIP users that call in, so it would display a warning especially to our first line call takers, that the specified user requires special attention, and would require the call taker to accept the message before continuing, is this functionality already included with ServiceNow or would this need to be scripted, either way I'm hoping that someone could advise the correct way to get this implemented.

 

Many thanks

18 REPLIES 18

Hi Ben, thank you for your update. Sounds like Chris' solution with a pop-up message that requires an interactive click to acknowledge will better meet your user requirement. Hope it works out well. Thanks, JohnG


Hi John/Chris,



Hope you can help - I need to do something similar, but instead of it being related to 'VIPs' I just want to show an alert when a specific customer calls the Service Desk - in order to ensure the analyst taking the call knows the customer has a visual impairment.



I have tried playing around with the script you provided but have not had much luck getting it to work.



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


    if (isLoading || newValue == '') {


          return;


    }



        var caller = g_form.getReference('caller_id');


        {


                  if(caller == "Test Customer"){


                            alert("This is a VIP");


                  }


        }


}



I'm presuming the value needs to be the 'full name' in the user record, although I have tried user ID and sys ID too.



Any help much appreciated.



Thank-you,


Daniel



Update: I've got as far as an alert showing using below client script.



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


if (isLoading || newValue == '') {


return;


}



var caller = g_form.getValue('caller_id');


{


if(caller == "


b888627738204100715909e1903afb1f"){


alert("Please note this customer has a visual impairment");


}


}


}




However please can you let me know how I can use the display value e.g. 'Test Customer' instead of the sys ID. I have tried the below but it is not working



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


if (isLoading || newValue == '') {


return;


}



var caller = g_form.getValue('caller_id');


var value = caller.getDisplayValue();


{


if(value == "Test Customer"){


alert("Please note this customer has a visual impairment");


}


}


}




The following error appears:



onChange script error: TypeError: caller.getDisplayValue is not a function function onChange_incident_caller_id_2(control, oldValue, newValue, isLoading, isTemplate) { if (isLoading || newValue == '') { return; } var caller = g_form.getValue('caller_id'); var value = caller.getDisplayValue(); { if(value == "Test Customer"){ alert("Please note this customer has a visual impairment"); } } }



Many thanks,


Daniel


Hi Dasi,



I usually avoid linking a script to a name/string field because the value can vary. I tend to like a true/false field on the user record to denote a special attribute of the user.



Nevertheless, this may work for you:



When:onChange


Field: Caller


Script:


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


    if (isLoading || newValue == '') {


          return;


    }



        var caller = g_form.getReference('caller_id', callback);


        function callback(caller){


                  if(caller.name == "Test Customer"){


                            alert("This is a Visually Impaired Customer");


                            g_form.showFieldMsg('caller_id','Please note this customer has a visual impairment','error');


                  }


        }


}



A possible solution is to add a custom field u_visual_impairment boolean field on the sys_user table.   Then you can set that flag for those customers.



When:onChange


Field: Caller


Script:


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


    if (isLoading || newValue == '') {


          return;


    }



        var caller = g_form.getReference('caller_id', callback);


        function callback(caller){


                  if(caller.u_visual_impairment == "true"){


                            alert("Please note this customer has a visual impairment");


                            g_form.showFieldMsg('caller_id','Please note this customer has a visual impairment','error');


                  }


        }


}



Hope that helps,



John


Many thanks John, this seems to be working great!



Out of interest and for my understanding, what is the callback function actually doing here and can I ask why we need 'error' at the end of the g_form.showFieldMsg?



Thanks again,


Daniel


Hi Daniel,



Glad it seems to be working for you. The callback function provides a little better performance for the processing of the onChange client script. However, we are now encouraged to use AJAX calls or g_scratchpad. For reference: Client Script Best Practices - ServiceNow Wiki



As for 'error' for the g_form.showFieldMsg, that determines the type of message shown beneath the field. I use 'error' to draw attention, but you can also use 'info'.   For reference: http://wiki.servicenow.com/index.php?title=Display_Field_Messages#Example



Cheers,



John