Help with Updating Custom Field via Item Approval Workflow in Business Central 2023 Wave 2 (On-Prem)

Hi everyone,
In Business Central 2023 Wave 2 (On-Premises), I’m trying to implement the standard “Item Approval Workflow”, but I’ve noticed that it does not automatically prevent users from using items in transactions (e.g., on sales documents).

To handle this, I’ve added a custom field called "Approval Status" to the Item table. My goal is to update this field when an approval request is sent and when a response (approval/rejection) is received.
Here’s what I’ve implemented so far:
:one: Item Table Extension (ItemExt.tableextension.al)
tableextension 50210 ItemExt extends Item
{
fields
{
field(50100; “Approval Status”; Enum “Item Approval Status”)
{
Caption = ‘Approval Status’;
DataClassification = ToBeClassified;
// Default = Draft;
}
}
}
:two: Enum Definition (Item Approval Status_.Enum.al)
enum 50210 “Item Approval Status”
{
Extensible = true;

value(0; Draft) { Caption = 'Draft'; }
value(1; "Pending Approval") { Caption = 'Pending Approval'; }
value(2; Approved) { Caption = 'Approved'; }

}
:three: Item Card Page Extension (ItemCardExt.PageExt.al)
pageextension 50210 ItemCardExt extends “Item Card”
{
layout
{
addlast(Item)
{
field(“Approval Status”; Rec.“Approval Status”)
{
ApplicationArea = All;
}
}
}
}
:four: Blocking Unapproved Items in Sales Lines (BlockUnapprovedItems.codeunit.al)
tableextension 50211 SalesLineExtension extends “Sales Line”
{
fields
{
modify(“No.”)
{
trigger OnAfterValidate()
begin
ValidateItemNo();
end;
}
}

local procedure ValidateItemNo()
var
    ItemRec: Record Item;
begin
    if ItemRec.Get(Rec."No.") then begin
        if ItemRec."Approval Status" <> ItemRec."Approval Status"::Approved then
            Error('Item "%1" cannot be used because it is not approved. Current status: %2.', ItemRec."No.", Format(ItemRec."Approval Status"));
    end;
end;

}

What I Need Help With

How can I integrate this custom Approval Status field with the standard Item approval workflow so that:

  • When an approval request is sent, the field is updated to "Pending Approval".
  • When the request is approved, the field changes to "Approved".
  • Optionally, if the request is rejected, the field returns to "Draft".

Any suggestions or examples would be greatly appreciated!