To use custom fields like Budgetted and Urgent in Workflow filters, you need to expose them in the workflow event conditions using the AddWorkflowTableRelation and AddWorkflowField methods in AL.
✅ Here's how you can do it:
1. Extend the Purchase Header table to add your custom Boolean fields.
2. Create a Workflow Event Handling subscriber (codeunit) and register your fields:
[EventSubscriber(ObjectType::Codeunit, Codeunit::"Workflow Setup", 'OnAddWorkflowTableRelations', '', false, false)]
local procedure AddWorkflowTableRelations()
begin
WorkflowSetup.AddWorkflowTableRelation(Database::"Purchase Header");
end;
[EventSubscriber(ObjectType::Codeunit, Codeunit::"Workflow Setup", 'OnAddWorkflowFieldsToRecord', '', false, false)]
local procedure AddWorkflowFieldsToRecord(TableID: Integer)
var
PurchaseHeader: Record "Purchase Header";
begin
if TableID = Database::"Purchase Header" then begin
WorkflowSetup.AddWorkflowField(PurchaseHeader.FieldNo("Budgetted"));
WorkflowSetup.AddWorkflowField(PurchaseHeader.FieldNo("Urgent"));
end;
end;
3. Reopen the workflow setup page, and your new fields should appear in the conditions filter dropdown.
This way, you can trigger approvals only when both Budgetted = true and Urgent = true.
✅ Mark this answer as verified if it helps you.