Why is this so difficult? Creating an alert to show when a caller is a member of a particular group.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago - last edited 3 weeks ago
I have run this scenario in the community, Google and Copilot multiple ways and there are so many different ways this can be done I'm getting confused because each one I try does not work. Can someone provide a script to do the following:
When a name is entered into the caller id field on the Incident form, check if the caller id is a member of a group.
Caller_ID: Jen Nocode
Group: Pilot_Participant
If, yes Jen Nocode is a member of the Pilot Participant group = show an alert telling the call taker the user is a pilot participant
If No, no alert needed
Some solutions provided had me create a Business Rule and a Client Script, some had just a Client Script.
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
You cannot validate server-side functions directly from client script. You need to first create script include function that is client callable and create a client script to call the script include.
Below is a reference,
You can finetune for your requirements and it should work.
Script Include
var CheckmemberOf = Class.create();
CheckmemberOf.prototype = Object.extendsObject(AbstractAjaxProcessor, {
checkGroupMember: function() {
var grp = this.getParameter('sysparm_grp');
return gs.getUser().isMemberOf(grp);
},
type: 'CheckmemberOf'
});
Client Script
function onLoad() {
var ga = new GlideAjax('CheckmemberOf');
ga.addParam('sysparm_name', 'checkGroupMember');
ga.addParam('sysparm_grp', 'group sys_id');
ga.getXML(checkGroup);
}
function checkGroup(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
if (answer == 'true') {
alert('User is a Pilot Participant');
}
}
If this helped to answer your query, please mark it helpful & accept the solution.
Thanks,
Bhuvan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Did you get a chance to review this as I believe provided information would fulfill your requirements.
As per community guidelines, you can accept more than one answer as accepted solution. If my response helped to answer your query, please mark it helpful & accept the solution.
Thanks,
Bhuvan