Automatically approving change request
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2017 12:33 PM
We created a business rule, based on sysapproval_approver, that should automatically approve a change request if the creator of the change request is a member of the approval group. The script seems to work, but the change request then throws an "invalid update" error, and the state of the change request moves back to new. Has anyone else encountered this? Is there a better way to achieve this same functionality?
Here's the code we're using:
skipSupervisorApproval();
function skipSupervisorApproval(){
var sys_user_table = new GlideRecord('sys_user');
var creater_sys_id;
sys_user_table.addQuery('user_name', current.sys_created_by);
sys_user_table.query();
while(sys_user_table.next()) {
creater_sys_id = sys_user_table.sys_id;
if(creater_sys_id == current.approver){
//set the state to approved and add comments
current.state = 'approved';
current.comments = "Marked by system as 'Approved' because I requested the approval and I am also in the approver group.";
}
}
}
- Labels:
-
Change Management