UI Action for Request Approval button for change

Suresh_32
Tera Expert

Hi All,

 

'Request Approval' button is not working if change type is Retro or Emergency.

'Request Approval' button is working if change type is Normal.

 

The existing code for is shown below. When you update the 'Approval Group' field in the change form without saving it, the 'Request Approval' button should not be submitted and a pop-up message should appear.

 

The 'Approval Group' field appears only in the 'Normal' change form , but not appears in the 'Retro and Emergency' change forms.

 

Please correct the following code for Retro and Emergency changes also.

 

Please assist me on this issue

 

UI Action for "Request Approval":

Onclick: checkgrp();

Condition : current.isValidRecord() && current.state == '10' && new HideRequestApproval().groupHasNoMembers(current.u_approval_group) && new HideRequestApproval().groupHasInActiveMembers(current.u_approval_group)

 

UI Script :

// current.state = '10';
// action.setRedirectURL(current);
// current.approval = 'requested';
// current.update();

function checkgrp() {
var ajax = new GlideAjax('ValidateApprovalGroup');
ajax.addParam('sysparm_name', "getApprovalGroup");
ajax.addParam('sysparm_existingsys', g_form.getUniqueValue());
ajax.getXML(getdata);

function getdata(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
if (answer.toString() == g_form.getValue("u_approval_group")) { //if both are same then only update else throwing the error
gsftSubmit(null, g_form.getFormElement(), 'request.approval');

} else {
alert("Before click on the 'Request Approval' button \nPlease Save the form");
}
}
}
if (typeof(window) == 'undefined')
updateAndRedirect();

function updateAndRedirect() {
current.state = '10';
action.setRedirectURL(current);
current.approval = 'requested';
current.update();
}

 

Script Include code:

var ValidateApprovalGroup = Class.create();
ValidateApprovalGroup.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getApprovalGroup: function() {
var gr = new GlideRecord("change_request");
gr.addQuery("sys_id", this.getParameter("sysparm_existingsys"));
gr.query();
if (gr.next()) {
return gr.getValue("u_approval_group");
}
},
type: 'ValidateApprovalGroup'
});

5 REPLIES 5

Saurav11
Kilo Patron
Kilo Patron

Hello,

 

So is the button no visible?

 

In the condition I see 

 

HideRequestApproval().groupHasNoMembers(current.u_approval_group) && new HideRequestApproval().groupHasInActiveMembers(current.u_approval_group) and the approval grp field is only for normal change?

 

Is that correct?

Hi Saurav,

 

Thanks you for your reply, Yes correct the above condition for only normal change only

 

u_approval_group field is appears only in the 'Normal' change form , but not appears in the 'Retro and Emergency' change forms

 

Thanks

Suresh

Hello,

 

But if you looks at the condition nd the script we need the u_approval_group field why not bring it on the form for  'Retro and Emergency' change it should solve the issue right?

Hi Saurav,

 

Can you please provide the correct code.