Make the comments mandatory when rejecting the Approval
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2023 11:12 PM - edited 12-05-2023 11:15 PM
In the below widget when user click the reject button we have to show the pop up asking reason for cancellation and it should be copied to request's work notes
The widget name is "approval info "
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2023 11:25 PM - edited 12-06-2023 12:00 AM
Hi @Black Coder ,
Doesn't this happen OOTB like whenever anyone rejects the approval they are asked for mentioning the reason & it gets captured in the worknotes/comments.?
Thanks,
Danish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2023 11:45 PM - edited 12-06-2023 12:06 AM
Hi @Black Coder ,
We had similar requirements to add worknotes if user rejects approval. We have cloned the OOB Approval Info widget & done the changes on the client script as,
function ($scope, spUIActionsExecuter, spUtil, spModal,$window) {
var c = this;
var ESIGNATURE = {
"approved": "cbfe291147220100ba13a5554ee4904d",
"rejected": "580f711147220100ba13a5554ee4904b"
};
//spUtil.recordWatch($scope, "sysapproval_approver", "state=requested^sys_id="+ c.data.sys_id);
c.action = function(state) {
if(c.data.esignature.e_sig_required) {
var requestParams = {
username: c.data.esignature.username,
userSysId: c.data.esignature.userSysId
};
spUIActionsExecuter.executeFormAction(ESIGNATURE[state], "sysapproval_approver" , c.data.sys_id, [] , "", requestParams).then(function(response) {
});
} else {
if(state=='rejected'){
spModal.prompt("Please enter rejection details", c.name).then(function(name) {
c.name = name;
if (c.name == null || c.name == "")
{
//Do Nothing
}
else{
c.data.op = state;
c.data.state = state;
c.data.rcomments=c.name;
c.server.update();
}
});
}
else{
c.data.op = state;
c.data.state = state;
c.server.update();
}
}
}
}
Server side changes
var recGr = new GlideRecord('tablename');
if (input && input.op) {
gr.state = input.op;
if(input.op=='rejected' && gr.state.changesTo('rejected'))
{
gr.comments = input.rcomments;
if(recGr.get(data.reqSys_id)){
recGr.work_notes =input.rcomments;
recGr.update();
}
}
gr.update();
}
While creating link for approval you need to pass parameters such as page id, table id & approval record's sys ID refer the approval link for OOB widget.
Please check and Mark Helpful and Correct if it really helps you.
Regards,
Mayur Shardul