Change management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
a month ago
Desc: "As the Change Management Process Owner, I need a way to allow ad-hoc approvals to be added on the fly by Change implementers so that approvals which cannot be automatically identified at time of raising can be manually added before the Change moves into Scheduled state. "
I need help for this . pls share steps how to configure it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago - last edited 3 weeks ago
Hi @Siddhac,
You can do this by creating a UI action button and script include.
Here's the steps below to achieve this:
- Open System Definition > UI Actions & create a new record
- Name it and select change_request table in the table field
- Check Active, Show Update, Client, Form Button fields
- Write "addAdhocApprover();" in OnClick field
- Write "current.state == '-2' || current.state == '-3' || current.state == '-4'" in Condition field
- Paste the following script in Script field:
function addAdhocApprover() {
var userSysId = prompt("Enter Approver Sys ID (or leave empty to cancel):");
if (!userSysId) {
g_form.addErrorMessage('No approver provided.');
return;
}
var ga = new GlideAjax('ChangeRequestUtils');
ga.addParam('sysparm_name', 'addApprover');
ga.addParam('sysparm_change_sys_id', g_form.getUniqueValue());
ga.addParam('sysparm_approver_sys_id', userSysId);
ga.getXMLAnswer(function(answer) {
if (answer === 'success') {
g_form.addInfoMessage('Ad-hoc approver added successfully.');
g_form.reloadRelatedList('approvers');
} else {
g_form.addErrorMessage('Failed to add ad-hoc approver.');
}
});
}- Now save it.
- Next you need to define the Script include, open System Definition > Script Includes
- Name it "ChangeRequestUtils" as we have used it in above Ui action script
- Check Glide Ajax enabled
- Paste the following script in the Script field:
var ChangeRequestUtils = Class.create();
ChangeRequestUtils.prototype = Object.extendsObject(AbstractAjaxProcessor, {
addApprover: function() {
var changeSysId = this.getParameter('sysparm_change_sys_id');
var approverSysId = this.getParameter('sysparm_approver_sys_id');
if (gs.nil(changeSysId) || gs.nil(approverSysId)) {
return 'failure';
}
var approver = new GlideRecord('sysapproval_approver');
approver.initialize();
approver.setValue('sysapproval', changeSysId);
approver.setValue('approver', approverSysId);
approver.setValue('state', 'requested');
approver.insert();
return 'success';
},
type: 'ChangeRequestUtils'
});
- Now test it by creating a new record in change_request table.
- Set state to Assess & save the record
- Click on Add Ad-Hoc Approval button
- Enter sys_id of any user you want to add as approver (not recommended in production, use appropriate approach)
- Now you can see the Adela Cervantsz in given Approvers related list as I entered the sys_id of this user.
Hope this helps!
If my response helped, please mark it as the accepted solution and helpful so others can benefit as well.
