Need script to create alert when changing assignment group
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-07-2022 08:47 AM
Having some issues creating a script that creates a pop-up when the assignment group changes from "Helpdesk" to "Messaging".
Currently, I can get the alert to appear whenever a ticket is opened (regardless of the current assignment group, or what it's changed to), or no alert at all.
I've gone through various "drafts" of a script, and the current one I have gives me an error that I can't use "current.assignment_group" in a client script.
Below is the code I have now where I get the error about the "current" use.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
//Type appropriate comment here, and begin script below
var GroupOld = previous.assignment_group;
var GroupNew = current.assignment_group;
if ((GroupOld == "Helpdesk") && (GroupNew == "Messaging")) {
alert('Notify London');
}
}
I can't seem to figure out how to properly use the "g_form(GetValue)" option. Can someone point me in the right direction, or provide a code that will work for what I'm trying to do?
Thanks in advance!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-07-2022 08:51 AM
Hello ,
Instead of current and previous object please use g_form object.
Curent and previous -- > Used in server side
g_form-->used in client side
var new = g_form.getValue('assignment_group'); //to get the new value
var old = oldValue;
just replace these lines and try
please accept this solution if this helps you

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-07-2022 08:56 AM
Hello Gary,
Actually this problem is deeper than this.
g_form.getValue('assignment_group') is only going to give you the new value and only the sysid of the group selected.
We could directly use sysid comparisons as shown below, but its not a good way.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
if ((oldValue == "<<sysid of Helpdesk group>>") && (newValue == "<<sysid of Messaging group>>")) {
alert('Notify London');
}
}
As the above code involves directly using sysid , its not best practice.
I suggest you write a glideajax , pass the old value (sysid) and new value(sysid) to script include, find the names of the groups and then throw alert on the client script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-08-2022 06:22 AM
How would I write a glideajax to change the sysid to a name?