- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-02-2022 11:29 AM
When click the "Request Approval" button is not working for Retro and Emergency change forms.
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)
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());
gs.addInfoMessage(gs.getMessage("Test Message123"));
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');
gs.addInfoMessage(gs.getMessage("Test Message1234"));
} 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();
}
screen shot for UI Action - 'Request approval' button in change form
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'
});
Please help on this issue.
Solved! Go to Solution.
- Labels:
-
Change Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-05-2022 10:10 AM
Hi @Sravani47,
It seems you are modifying your UI action to check some conditions in on-click function for Normal change request.
I would recommended you to create a new UI action that will work for Normal change request and keep existing UI action for remaining change requests with type is normal.
Kindly hit Kudos and mark it correct based on your impact!
Thanks,
Sagar Pagar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-05-2022 10:10 AM
Hi @Sravani47,
It seems you are modifying your UI action to check some conditions in on-click function for Normal change request.
I would recommended you to create a new UI action that will work for Normal change request and keep existing UI action for remaining change requests with type is normal.
Kindly hit Kudos and mark it correct based on your impact!
Thanks,
Sagar Pagar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2022 01:50 AM
Thank you Sagar, it's working as expected.
Good Work!!!