Reassign Approval After Requested

Kerry10
Giga Expert

I have a request to allow users to reassign an approval after it has been requested.

I couldn't find any OOB functionality that is like this, so I figured I have to make my own UI action.

I am trying to think of the best way to do this. Ideally, when the button is clicked I would like a pop up to appear with a reference field for the user table, and then when they submit, the approval will be reassigned to this value.

I have made a UI action with a client side pop up window before, but it only had plain text. How can I make a "mini form" appear as a pop up? 

I'm looking for any help with this, or im open to any alternate suggestions!

thanks.

1 ACCEPTED SOLUTION

I created a basic UI page, and script include to make the change to the approval record.

Here are the details. the items in BOLD will change based on what you name the records.

UI ACTION:

function popupWindow() {

var dialog = new GlideDialogWindow('x_25054_reassign_a_Reassign approval');
dialog.setTitle("Approval Re-assign");
dialog.setSize(500,225);
dialog.adjustBodySize();
dialog.render();

return false;
}

 

UI PAGE:

HTML - 

<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<h2 >Re-assign this approval</h2>

<g:ui_form>

<tr><td>Re-assign to: </td><td><g:ui_reference name="newUser" table="sys_user" completer="AJAXTableCompleter" columns="first_name" /></td></tr>
<tr><td></td></tr>

<g:dialog_buttons_ok_cancel ok="validateChanges();" cancel="processCancel();" ok_type="button" cancel_type="button" />


</g:ui_form>

</j:jelly>

 

CLIENT SCRIPT - 

function validateChanges(){

var user = gel("newUser").value;
var id = gel('sys_uniqueValue').value;
GlideDialogWindow.get().destroy();
var ga = new GlideAjax('reAssignApprover');
ga.addParam('sysparm_name', 'reAssign');
ga.addParam('sysparm_user', user);
ga.addParam('sysparm_id', id);
ga.getXML();
}

function processCancel(){
GlideDialogWindow.get().destroy();
}

 

SCRIPT INCLUDE: 

var reAssignApprover = Class.create();
reAssignApprover.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {

reAssign: function(){
var user = this.getParameter('sysparm_user');
var id = this.getParameter('sysparm_id');
var gr = new GlideRecord('sysapproval_approver');
gr.get(id);
gr.query();
while(gr.next()){
gr.setValue('approver',user);
gr.update();
}
gs.addInfoMessage('This approval record has been re-assigned');
},

type: 'reAssignApprover'
});

 

Hope this helps. let me know if you still need some help. 

 

View solution in original post

25 REPLIES 25

Inactive_Us1180
Kilo Guru

I agree with Puneetgoels above. the easiest way would to just add a field on the form. 

otherwise you can do a Dialog window that references a UI page. but that takes a little more effort. 

I can't think of a way to put the field on the form without it looking messy. I don't want the "reassign to" field always there. I'd rather it be a UI action button or link that launches the reassign "process" (Which is just entering a new name).

I'll take any suggestions however

gotcha, I think what you are looking for is a GlideDialogWindow

 

something like this...

function popupWindow() {

var sys_id = g_form.getValue('sys_id');
var dialog = new GlideDialogWindow('UI PAGE ENDPOINT HERE');
dialog.setTitle("Approval Re-assign");
dialog.setPreference('currentRecord', sys_id);
dialog.setSize(500,225);
dialog.adjustBodySize();

dialog.render();

}

 

you would need to create the UI page. Are you familiar with those? if not, then I can help you out there. 

Sorry for the late response.

 

Yes! I think this is what im looking for. I'm slightly familiar with UI pages but could definitely use a push in the right direction. I was looking for a ui page to use as a template that's similar to what I'm trying to do...such as service_management_task_closed_incomplete, but I'm not sure if that's the best one to use. Any help would be much appreciated.

I created a basic UI page, and script include to make the change to the approval record.

Here are the details. the items in BOLD will change based on what you name the records.

UI ACTION:

function popupWindow() {

var dialog = new GlideDialogWindow('x_25054_reassign_a_Reassign approval');
dialog.setTitle("Approval Re-assign");
dialog.setSize(500,225);
dialog.adjustBodySize();
dialog.render();

return false;
}

 

UI PAGE:

HTML - 

<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<h2 >Re-assign this approval</h2>

<g:ui_form>

<tr><td>Re-assign to: </td><td><g:ui_reference name="newUser" table="sys_user" completer="AJAXTableCompleter" columns="first_name" /></td></tr>
<tr><td></td></tr>

<g:dialog_buttons_ok_cancel ok="validateChanges();" cancel="processCancel();" ok_type="button" cancel_type="button" />


</g:ui_form>

</j:jelly>

 

CLIENT SCRIPT - 

function validateChanges(){

var user = gel("newUser").value;
var id = gel('sys_uniqueValue').value;
GlideDialogWindow.get().destroy();
var ga = new GlideAjax('reAssignApprover');
ga.addParam('sysparm_name', 'reAssign');
ga.addParam('sysparm_user', user);
ga.addParam('sysparm_id', id);
ga.getXML();
}

function processCancel(){
GlideDialogWindow.get().destroy();
}

 

SCRIPT INCLUDE: 

var reAssignApprover = Class.create();
reAssignApprover.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {

reAssign: function(){
var user = this.getParameter('sysparm_user');
var id = this.getParameter('sysparm_id');
var gr = new GlideRecord('sysapproval_approver');
gr.get(id);
gr.query();
while(gr.next()){
gr.setValue('approver',user);
gr.update();
}
gs.addInfoMessage('This approval record has been re-assigned');
},

type: 'reAssignApprover'
});

 

Hope this helps. let me know if you still need some help.