Create a generic alert message on the user table

SMuir
Mega Guru

Can someone help me with this query please.

We want to create a generic alert message that can be changed.

For example.

Create a tick box called Alert message

Create a text field to show when the alert message has been ticked on a certain user.

Enter the message for example. Blackberry pilot

When a Service Desk Analyst logs a call and selects the user. It will display a message Blackberry Pilot.

If the same tick box and a different message is applied on another user in the user table. Say the message is Laptop pilot it will show that message.

Does anyone know if this will work or done something similar? for example if someone is part of two pilots how can the message be applied?

Kind Regards

Sarah

1 ACCEPTED SOLUTION

Hi Sarah,



I'll assume you have a field on your table called u_active which is a true/false field. You can add that to your script include query (before the msg.query() statement) something like this:



msg.addQuery('u_active', true);



If my assumptions are incorrect, adapt the statement or let me know the field name, type, value, etc. and I can advise.



Thanks.


View solution in original post

25 REPLIES 25

Chuck Tomasi
Tera Patron

Hi Sarah,



This is doable, but will require some scripting. Unfortunately I don't have time today to write it all out - someone in the community may volunteer for this. Here's my process for building out something like this:


  • Create a new table: ex: u_user_alert
    • Field: Reference field to sys_user
    • Field: True/false for on/off status
    • Field: String for text to display
  • Add the related list to sys_user - this is how you are going to get multiple notifications for one user
  • For each form and field you want to do this on (e.g. incident.caller_id) write an onChange client script for that field that does a GlideAjax call
    • The GlideAjax call will pass the new value of the user field to the server
    • The server will look up any active (on) notifications in u_user_alert table that are related to the user passed in then send back the text related to the messages it found
    • The client script gets the returned value and displays the messages


Hope that helps. Here's some reference information



Episode 33: TechNow Episode List


Docs: Client Scripts


Docs: GlideForm


Docs: GlideAjax


Client Script Best Practices - ServiceNow Wiki      


Thanks for this Chuck,



I will make a start on your suggestions but I will need help with the script if anyone is willing, This is not too urgent but I would like to have something in place by the end of the week if possible.



Kind Regards


Sarah


Check out the video I cited above (episode 23 of TechNow.) It talks specifically about returning complex GlideAjax information. You shouldn't have any issues adapting it to your needs.



Good luck!


SMuir
Mega Guru

Thanks for the Info Chuck. I did try and watch the technow 23 but it was very confusing for me with the screen switching and I have made no headway with this at all.



If anyone can help with the code for this I would appreciate it. I am not the best at coding and learning as I go.



Kind Regards


Sarah