Reassignment: reacting to it with an event
An open approval changes hands in four ways: a user hands it to somebody else in the Reassign Approval dialog, an escalation step passes it on, Business Central hands it to the substitute on record, or an administrator gives up a claimed entry. Partners and customers with their own development can react to every one of these — with an integration event that is raised after the handover and says who held the approval before and who holds it now.
This page is the developer contract: the event, its parameters, which way produces which values, and an example.
Typical use
A company also tracks its approvals in a ticket system of its own. When an approval moves, the ticket should follow the new assignee, so that nobody has to look in two systems. A subscriber writes every handover into a table of its own and makes the connection from there; the workflow itself is untouched.
The event
Publisher: codeunit DXP AWF Approval Entry Helper, integration event OnAfterApprovalReassigned. It is raised only after the handover has succeeded — so a subscriber may rely on the new approval entries existing, and on an entry still being open for the record.
| Parameter | Meaning |
|---|---|
InstanceID: Guid | The workflow instance the approval belongs to. |
RecordID: RecordId | The record whose approval changed hands — a document or one of its lines. |
AssignmentSource: Enum "DXP AWF Assignment Source" | What reassigned it: Reassignment when a user handed it on, Escalation for an escalation's reassign step. Blank for a delegation. |
SubstitutionReason: Enum "DXP AWF Substitution Reason" | Why somebody else holds it: Delegation, Escalation or Administrator. Blank for a reassignment. |
PreviousAssigneeType: Enum "DXP AWF Assignee Type" | Whom the approval was assigned to before. Blank on entries created before version 1.16 — those do not know their type. |
PreviousAssigneeCode: Code[50] | The previous approver, workflow user group or external approver. |
NewAssigneeType: Enum "DXP AWF Assignee Type" | Whom it is assigned to now. |
NewAssigneeCode: Code[50] | The new approver, workflow user group or external approver. |
Reason: Text | The reason the user gave. Empty on the ways that ask for none. |
The two enums are the ones the approval entry itself records: Assignment Source and Substitution Reason. A reassignment names an assignment source and leaves the substitution reason blank; a delegation does the opposite — it changes who holds an entry, not whom the stage assigned it to.
Which way produces which values
| Way | Assignment Source | Substitution Reason | Reason |
|---|---|---|---|
| Reassign Approval — the dialog, the Related approvals FactBox and the line subforms | Reassignment | blank | the user's mandatory entry |
| Escalation step "Reassign" | Escalation | blank | generated, naming the step no. and the days overdue |
| Escalation step "Delegate" | blank | Escalation | empty |
| Delegation to the substitute — Business Central's own way | blank | Delegation | empty |
| Administrator gives up a claim | blank | Administrator | empty |
A delegation always goes to a named user, never to a group: PreviousAssigneeType and NewAssigneeType are both Approver there.
Example: recording every handover
codeunit 50112 "MY AWF Reassignment Log"
{
[EventSubscriber(ObjectType::Codeunit, Codeunit::"DXP AWF Approval Entry Helper", 'OnAfterApprovalReassigned', '', false, false)]
local procedure LogHandover(InstanceID: Guid; RecordID: RecordId; AssignmentSource: Enum "DXP AWF Assignment Source"; SubstitutionReason: Enum "DXP AWF Substitution Reason"; PreviousAssigneeType: Enum "DXP AWF Assignee Type"; PreviousAssigneeCode: Code[50]; NewAssigneeType: Enum "DXP AWF Assignee Type"; NewAssigneeCode: Code[50]; Reason: Text)
var
Handover: Record "MY AWF Handover";
begin
// Only purchase documents are of interest here.
if RecordID.TableNo() <> Database::"Purchase Header" then
exit;
Handover.Init();
Handover."Instance ID" := InstanceID;
Handover."Record ID" := RecordID;
Handover."From Type" := PreviousAssigneeType;
Handover."From Code" := PreviousAssigneeCode;
Handover."To Type" := NewAssigneeType;
Handover."To Code" := NewAssigneeCode;
// A delegation gives no reason - the substitution reason says it instead.
if Reason = '' then
Handover.Reason := Format(SubstitutionReason)
else
Handover.Reason := CopyStr(Reason, 1, MaxStrLen(Handover.Reason));
Handover."Logged At" := CurrentDateTime();
Handover.Insert(true);
end;
}
What the event does not do
- It cannot be cancelled. It has no
IsHandledparameter and is raised only once the handover has already happened. - Advanced Workflow approvals only. Entries without a workflow instance — from a BC standard workflow, for example — do not raise it.
- No event without a handover. If the record has no open Advanced Workflow approval, nothing happens and the event stays out.
- An error in a subscriber does not undo the handover; it leaves an error message with the user who triggered it.
- The Audit Trail records the handover anyway. The event is meant for reacting to it, not as a replacement for it.
Related pages
- Module: Approval Reassignment
- Proposed assignee: setting it with an event — deciding what the dialog proposes before the user confirms
- Module: Escalation Engine — the "Reassign" and "Delegate" steps