Closed jacebenson closed 5 years ago
Thank / Attribute Derek.
A few days ago Derek was asking about approvals, specifically approvals for Knowledge articles and why they don't work out of the box. It's weird and here I'll go through it.
So it seems Servicenow started to make this work out of the box but just never finished it. Here's the list of things they did;
Knowledge - Approval Publish
creates an approvalA business rule called Approval Events (Non-Task)
triggers an event for the state. Here's the code;
sendEventsNonTask();
function sendEventsNonTask() {
if (!current.state.changes())
return;
var event = current.source_table;
switch (current.state + "") {
case 'cancelled':
event += ".approval.cancelled";
gs.eventQueue(event, current, gs.getUserID(), gs.getUserName());
break;
case 'requested':
event += ".approval.inserted";
gs.eventQueue(event, current, gs.getUserID(), gs.getUserName());
updateRecord(current, current.approver.getDisplayValue() + " requested to approve task");
break;
case 'rejected':
event += ".approval.rejected";
gs.eventQueue(event, current, current.state, previous.state);
updateRecord(current, current.approver.getDisplayValue() + " rejected the task.",
current.comments.getJournalEntry(-1));
notifyMyFriends(current);
break;
case 'approved':
updateRecord(current, current.approver.getDisplayValue() + " approved the task.",
current.comments.getJournalEntry(-1));
break;
default:
}
}
/*Omitted remaining code...*/
change.itil.approve.role
Subject: ${sysapproval.sys_class_name} ${sysapproval} Approval Request
<div>Short Description: ${sysapproval.short_description}</div>
<div>Priority: ${sysapproval.priority}</div>
<div>Category: ${sysapproval.category}</div>
<div> </div>
<div>
<div><hr /></div>
</div>
<div>${mail_script:change_request_summary}</div>
<div> </div>
<div>Comments:</div>
<div>${sysapproval.description}</div>
<div>
<div><hr /></div>
</div>
<div>${mailto:mailto.approval}</div>
<div>
<div><hr /></div>
</div>
<div>${mailto:mailto.rejection}</div>
<div>
<div><hr /></div>
</div>
<div>Approval Activity:</div>
<div>${mail_script:approval_activity}</div>
<div>
<div><hr /></div>
</div>
<div>Click here to view Approval Request: ${URI}</div>
<div>Click here to view ${sysapproval.sys_class_name}: ${sysapproval.URI}</div>
Subject: ${sysapproval.sys_class_name} ${sysapproval} Approval Request
<div>Short Description: ${document_id.short_description}</div>
<div> </div>
<div>
<div><hr /></div>
</div>
<div>${mailto:mailto.approval}</div>
<div>
<div><hr /></div>
</div>
<div>${mailto:mailto.rejection}</div>
<div>
<div><hr /></div>
</div>
<div>Click here to view Approval Request: ${URI}</div>
<div>Click here to view ${document_id.sys_class_name}: ${document_id.URI}</div>
They made it really close. Just never finished it.
In anycase, thanks Derek for the idea for the post.
What is the post about? Approvals for Knowledge and how there is a unused event,
kb_knowledge.approval.inserted
That event is not registered in the event registry. There is no notification tied to the event.What things would help with writing the post https://community.servicenow.com/community?id=community_question&sys_id=28a84f21db5cdbc01dcaf3231f961994