Would like to use a UI Action button to change a previously populated assignment group to a new one

Hola Ola
Giga Guru

Hello all,

I am trying to figure HOW to make a populated Assignment Group name to change to a different one, when a UI Action button is clicked.

 

Use case: (see attachment)

I want to change/replace the AppDev (or any group name) in the Assignment Group field to Mis-Assigned Incidents group when the Mis-Assigned Incident UI Action button is clicked. 

 

MisAss.png

 

Here is the UI button information:

Order: 100

Action Name: mis_assigned_incident

Active / Show Insert/ Show Update / Client / List v2 & v3 Compatible / Form Button

Comments: Reassign Incident to the Mis-Assigned Group when Incident was assigned incorrectly.

Onclick: loadConfirmDialog();

Condition: current.state == '2' || current.state == '3' && current.priority !== 1

 

 

Script:
var rejectconfirmDialog;
 
function loadConfirmDialog() {
//var dialogClass = window.GlideModal ? GlideModal : GlideDialogWindow;
rejectconfirmDialog = new GlideDialogWindow("mis_assigned_confirm", false, 648, 250);
rejectconfirmDialog.setTitle(new GwtMessage().getMessage("Please provide a reason on why this record is being sent to the Mis-Assigned Queue. NOTE: If you know the group this record should be assigned to, please route directly to them or contact the Service Desk Leadership Team for advice.")); //Modify title to display on popup
rejectconfirmDialog.render();
}
 
function commentsDialog(notes) {
//g_form.setValue("state",1) Possible to set the state here.
g_form.setValue("work_notes", notes); //Pass reason worknotes to a field
rejectconfirmDialog.destroy();
gsftSubmit(null, g_form.getFormElement(), "mis_assigned_incident"); // Call UI action to run server script
 
}
 
if (typeof window == 'undefined')
   setRedirect();
 
function setRedirect() {
    current.update();
gs.eventQueue("mis.assigned.incident", current, gs.getUserName());
    action.setRedirectURL(current);
}
 
current.assignment_group.setDisplayValue("Mis-Assigned Incidents");
if (current.isValidRecord()) {
    // this is when close is called as an update, just update it
    current.update();
} else {
    // and insert the record
    current.insert();
}
current.assignment_group = current.assignment_group.getDisplayValue("Mis-Assigned Incidents");
current.assignment_group = GetIDValue('sys_user_group', 'Mis-Assigned Incidents');

 

3 REPLIES 3

shyamkumar VK
Kilo Patron

Hello @Hola Ola 

here is the updated code 

Script:
var rejectconfirmDialog;
 
function loadConfirmDialog() {
//var dialogClass = window.GlideModal ? GlideModal : GlideDialogWindow;
rejectconfirmDialog = new GlideDialogWindow("mis_assigned_confirm", false, 648, 250);
rejectconfirmDialog.setTitle(new GwtMessage().getMessage("Please provide a reason on why this record is being sent to the Mis-Assigned Queue. NOTE: If you know the group this record should be assigned to, please route directly to them or contact the Service Desk Leadership Team for advice.")); //Modify title to display on popup
rejectconfirmDialog.render();
}
 
function commentsDialog(notes) {
//g_form.setValue("state",1) Possible to set the state here.
g_form.setValue("work_notes", notes); //Pass reason worknotes to a field
rejectconfirmDialog.destroy();
gsftSubmit(null, g_form.getFormElement(), "mis_assigned_incident"); // Call UI action to run server script
 
}
 
if (typeof window == 'undefined')
   setRedirect();
 
function setRedirect() {
    current.update();
gs.eventQueue("mis.assigned.incident", current, gs.getUserName());
    action.setRedirectURL(current);
}
 
current.assignment_group=SYSID of your assignment group;
if (current.isValidRecord()) {
    // this is when close is called as an update, just update it
    current.update();
} else {
    // and insert the record
    current.insert();
}
Please mark this as helpful and accept as a solution if this resolves your Ask.
Regards,

Shyamkumar

Community Alums
Not applicable

Hi Hola Ola,

I think you need to check the UI Page called for that. In general, you can easily do that in the Processing script section of your UI Page called from UI Action. 

Note - you can handle the assignment more easily if you just use server based UI Action - then you can just do current.assignment_group = <whatever is your sys_id> or use setValue() + current.update(); action.setURLRedirect(current) //if i remember it correctly...but for sure sometthing like that

shyamkumar VK
Kilo Patron

Hello @Hola Ola  ,

did you tried with the updated code?

Please mark this as helpful and accept as a solution if this resolves your Ask.
Regards,

Shyamkumar