- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-30-2017 05:16 AM
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
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-24-2017 08:31 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-23-2017 03:52 AM
With some help this is now working. However, I have had a further request to only show active messages.
Can someone advise me how best I can amend to script to show this please? Many thanks for the help in advance. I am slowing learning how to script and appreciate the help.
Client Script
function
onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (newValue === '' || isLoading) {
return;
}
var user = g_form.getValue('caller_id'); //get the value of the user from the
incident table
//alert(user);
// Print the value of user variable before sending this parameter to
script include
var ga = new GlideAjax('MessageMapper'); //create a variable for glide Ajax and
use the name of the Script Include has to match exactly
ga.addParam ('sysparm_name', 'getUser'); //gets
the name of the user
ga.addParam ('sysparm_user', newValue); //gets the value of the alert message
//alert(newValue); //
Print the value of alert message variable before sending this parameter to
script include.
ga.getXMLAnswer (alertMessageback); //gets the answers from the script
include and sends it to the clients browser
function alertMessageback(answer){
if (answer)
alert(answer); //displays the messages in the alert messages field
}
}
Script Include
var MessageMapper = Class.create();
- MessageMapper.prototype =
Object.extendsObject(AbstractAjaxProcessor, {
getUser :
function() {
var
MessageMapperID = this.getParameter('sysparm_user');
//gs.log
('message mapper MessageMapperid: '+ MessageMapperID);
var msg = new
GlideRecord('u_user_alert'); //Table which has the messages is 'u_user_alert'
msg.addQuery('u_user', MessageMapperID); //u_user is from the alert messages table
and queries the variable MessageMapperID in line 5 with the user
msg.query();
//get answers from the
server
var answer =
[]; //create a variable answer
while
(msg.next()) {
var message = msg.getValue('u_alert_message'); //get the value of the
message in the u_alert_message field
answer.push(message); //push the answers to the client script
//gs.log('messageMapper u_alert_message' + message);
}
return
answer.join('\n'); //returns the answers showing on new lines
},
type:
'MessageMapper'
});

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-24-2017 08:31 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-24-2017 08:37 AM
Thanks Chuck,
It's working now.
Regards
Sarah
Sarah Muir | IT ServiceNow Technician
Norton Rose Fulbright LLP
3 More London Riverside, London, SE1 2AQ, United Kingdom
Tel +44 20 7444 3835 | Mob +44 7738 808219 | Fax +44 20 7283 6500
sarah.muir@nortonrosefulbright.com
NORTON ROSE FULBRIGHT
Law around the world
nortonrosefulbright.com<http://www.nortonrosefulbright.com>
A powerful combination — Norton Rose Fulbright and Chadbourne & Parke will join forces in the second quarter of 2017.
nortonrosefulbright.com/chadbourne<http://www.nortonrosefulbright.com/chadbourne>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-07-2017 03:56 AM
Hi Chuck,
I have a question that you might be able to help me with. We seem to getting a 8-10 second lag to show the alert message. Is there a way the script can be tweaked for faster performance? I am not sure how I would do that.
I look forward to hearing from you and thank you for the help in advance.
Kind Regards
Sarah

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-07-2017 05:20 AM
Hi Sarah,
That's a bit extreme for a GlideAjax query. They are usually pretty quick. It could be anything from the browser, to another script intercepting the query. Due to the limitations of debugging via the community, I recommend reaching out to customer support. They can have eyes and hands on to get this resolved for you quickly.
HI Service Portal - ServiceNow