---
id: object/codeunit/1502
type: object
title: Codeunit 1502 "Workflow Setup"
summary: Codeunit 1502 "Workflow Setup" in Base Application (System.Automation). 93 public procedures, 5 events. Present since at least BC23, still in BC30, changed in BC24, BC28-29.
tier: official
language: en
tags:
  - codeunit
  - base application
versions:
  introduced: null
  last_changed: "29"
  deprecated: null
review:
  state: derived
  by: null
  at: null
  flags: []
generated:
  at: "2026-10-11T00:31:51.816Z"
  pipeline: 0.2.0
  prompts: {}
  input_hash: e72ecc396798da8a73504a5425c27a0d19be3e40e4c99a290001290265fef553
evidence:
  - kind: code
    url: https://github.com/microsoft/BCApps/blob/ea08af5ef2d6a9b5c5af4a029288abbe2c883220/src/Layers/W1/BaseApp/System/Workflow/WorkflowSetup.Codeunit.al
    title: src/Layers/W1/BaseApp/System/Workflow/WorkflowSetup.Codeunit.al (releases/29.x)
    date: null
    commit: ea08af5ef2d6a9b5c5af4a029288abbe2c883220
    t: null
    quote: null
links:
  learn: []
  objects: []
  features: []
  topics: []
  localizations: []
  videos: []
  posts: []
  guidelines: []
  changes:
    - change/bcapps/9601
object_type: codeunit
object_id: 1502
name: Workflow Setup
namespace: System.Automation
app: Base Application
extends: null
first_version: "23"
last_version: "30"
present_in:
  - "23"
  - "24"
  - "25"
  - "26"
  - "27"
  - "28"
  - "29"
  - "30"
changed_in:
  - "24"
  - "28"
  - "29"
source_major: "29"
obsolete: null
countries: []
ms_search_form_ids: []
counts:
  fields: 0
  procedures: 172
  events: 5
  subscribers: 0
relations:
  out: 0
  referenced_by: 0
  pages: 0
  extended_by: 0
  event_subscribers: 6
  calls: 5
  called_by: 13
  implements: 0
---

# Codeunit 1502 "Workflow Setup"

> Codeunit 1502 "Workflow Setup" in Base Application (System.Automation). 93 public procedures, 5 events. Present since at least BC23, still in BC30, changed in BC24, BC28-29.

Base Application · System.Automation · BC23-30 · [source at ea08af5e](https://github.com/microsoft/BCApps/blob/ea08af5ef2d6a9b5c5af4a029288abbe2c883220/src/Layers/W1/BaseApp/System/Workflow/WorkflowSetup.Codeunit.al) · facts from BC29

## Events published

- `OnInsertWorkflowTemplates()` (integration)
  - subscribers: [Codeunit 6139 "E-Document Workflow Setup"](../codeunit/6139.md) OnInsertWorkflowTemplates
- `OnAddWorkflowCategoriesToLibrary()` (integration)
  - subscribers: [Codeunit 6139 "E-Document Workflow Setup"](../codeunit/6139.md) OnAddWorkflowCategoriesToLibrary, [Codeunit 6280 "Sust. Workflow Event Handling"](../codeunit/6280.md) OnAddWorkflowCategoriesToLibrary
- `OnAllowEditOfWorkflowTemplates(var Allow: Boolean)` (internal)
  - subscribers: [Codeunit 104056 "Upgrade Workflow"](../codeunit/104056.md) AllowDeletionOfWorkflowTemplates
- `OnAfterInitWorkflowTemplates()` (integration)
  - subscribers: [Codeunit 6280 "Sust. Workflow Event Handling"](../codeunit/6280.md) InsertWorkflowTemplates
- `OnAfterInsertApprovalsTableRelations()` (integration)
  - subscribers: [Codeunit 6280 "Sust. Workflow Event Handling"](../codeunit/6280.md) OnAfterInsertApprovalsTableRelations

## Procedures

- `InitWorkflow()`
- `InsertWorkflowCategories()`
- `InsertWorkflowTemplate(var Workflow: Record Workflow; WorkflowCode: Code[17]; WorkflowDescription: Text[100]; CategoryCode: Code[20])`
- `ResetWorkflowTemplates()` (internal)
- `InsertApprovalsTableRelations()`
- `InsertIncomingDocumentApprovalWorkflowTemplate()`
- `InsertOverdueApprovalsWorkflow(): Code[20]`
- `InsertCustomerApprovalWorkflow()`
- `InsertVendorApprovalWorkflow()`
- `InsertItemApprovalWorkflow()`
- `JobQueueEntryWorkflowCode(): Code[17]`
- `IncomingDocumentWorkflowCode(): Code[17]`
- `IncomingDocumentApprovalWorkflowCode(): Code[17]`
- `IncomingDocumentOCRWorkflowCode(): Code[17]`
- `IncomingDocumentToGenJnlLineOCRWorkflowCode(): Code[17]`
- `PurchaseInvoiceWorkflowCode(): Code[17]`
- `PurchaseInvoiceApprovalWorkflowCode(): Code[17]`
- `PurchaseBlanketOrderApprovalWorkflowCode(): Code[17]`
- `PurchaseCreditMemoApprovalWorkflowCode(): Code[17]`
- `PurchaseQuoteApprovalWorkflowCode(): Code[17]`
- `PurchaseOrderApprovalWorkflowCode(): Code[17]`
- `PurchaseReturnOrderApprovalWorkflowCode(): Code[17]`
- `SalesInvoiceApprovalWorkflowCode(): Code[17]`
- `SalesBlanketOrderApprovalWorkflowCode(): Code[17]`
- `SalesCreditMemoApprovalWorkflowCode(): Code[17]`
- `SalesQuoteApprovalWorkflowCode(): Code[17]`
- `SalesOrderApprovalWorkflowCode(): Code[17]`
- `SalesReturnOrderApprovalWorkflowCode(): Code[17]`
- `OverdueNotificationsWorkflowCode(): Code[17]`
- `SalesInvoiceCreditLimitApprovalWorkflowCode(): Code[17]`
- `SalesOrderCreditLimitApprovalWorkflowCode(): Code[17]`
- `CustomerWorkflowCode(): Code[17]`
- `CustomerCreditLimitChangeApprovalWorkflowCode(): Code[17]`
- `VendorWorkflowCode(): Code[17]`
- `VendorBankWorkflowCode(): Code[17]`
- `ItemWorkflowCode(): Code[17]`
- `ItemUnitPriceChangeApprovalWorkflowCode(): Code[17]`
- `GeneralJournalBatchApprovalWorkflowCode(): Code[17]`
- `GeneralJournalLineApprovalWorkflowCode(): Code[17]`
- `ItemJournalBatchApprovalWorkflowCode(): Code[17]`
- `RequisitionWkshBatchApprovalWorkflowCode(): Code[17]`
- `SendToOCRWorkflowCode(): Code[17]`
- `InsertDocApprovalWorkflowSteps(Workflow: Record Workflow; DocSendForApprovalConditionString: Text; DocSendForApprovalEventCode: Code[128]; DocCanceledConditionString: Text; DocCanceledEventCode: Code[128]; WorkflowStepArgument: Record "Workflow Step Argument"; ShowConfirmationMessage: Boolean)`
- `InsertRecApprovalWorkflowSteps(Workflow: Record Workflow; ConditionString: Text; RecSendForApprovalEventCode: Code[128]; RecCreateApprovalRequestsCode: Code[128]; RecSendApprovalRequestForApprovalCode: Code[128]; RecCanceledEventCode: Code[128]; WorkflowStepArgument: Record "Workflow Step Argument"; ShowConfirmationMessage: Boolean; RemoveRestrictionOnCancel: Boolean)`
- `InsertRecChangedApprovalWorkflowSteps(Workflow: Record Workflow; RuleOperator: Option; RecChangedEventCode: Code[128]; RecCreateApprovalRequestsCode: Code[128]; RecSendApprovalRequestForApprovalCode: Code[128]; var WorkflowStepArgument: Record "Workflow Step Argument"; TableNo: Integer; FieldNo: Integer; RecordChangeApprovalMsg: Text)`
- `InsertGenJnlBatchApprovalWorkflowSteps(Workflow: Record Workflow; ConditionString: Text; RecSendForApprovalEventCode: Code[128]; RecCreateApprovalRequestsCode: Code[128]; RecSendApprovalRequestForApprovalCode: Code[128]; RecCanceledEventCode: Code[128]; WorkflowStepArgument: Record "Workflow Step Argument"; ShowConfirmationMessage: Boolean)`
- `InsertGenJnlLineApprovalWorkflowSteps(var Workflow: Record Workflow; EventConditions: Text; ApproverType: Enum "Workflow Approver Type"; LimitType: Enum "Workflow Approver Limit Type"; WorkflowUserGroupCode: Code[20]; SpecificApprover: Code[50]; DueDateFormula: DateFormula)`
- `InsertItemJnlBatchApprovalWorkflowSteps(Workflow: Record Workflow; ConditionString: Text; RecSendForApprovalEventCode: Code[128]; RecCreateApprovalRequestsCode: Code[128]; RecSendApprovalRequestForApprovalCode: Code[128]; RecCanceledEventCode: Code[128]; WorkflowStepArgument: Record "Workflow Step Argument"; ShowConfirmationMessage: Boolean)`
- `InsertRequisitionWkshBatchApprovalWorkflowSteps(Workflow: Record Workflow; ConditionString: Text; RecSendForApprovalEventCode: Code[128]; RecCreateApprovalRequestsCode: Code[128]; RecSendApprovalRequestForApprovalCode: Code[128]; RecCanceledEventCode: Code[128]; WorkflowStepArgument: Record "Workflow Step Argument"; ShowConfirmationMessage: Boolean)`
- `InsertPurchaseDocumentApprovalWorkflowSteps(var Workflow: Record Workflow; DocumentType: Enum "Purchase Document Type"; ApproverType: Enum "Workflow Approver Type"; LimitType: Enum "Workflow Approver Limit Type"; WorkflowUserGroupCode: Code[20]; DueDateFormula: DateFormula)`
- `InsertSalesDocumentApprovalWorkflowSteps(var Workflow: Record Workflow; DocumentType: Enum "Sales Document Type"; ApproverType: Enum "Workflow Approver Type"; LimitType: Enum "Workflow Approver Limit Type"; WorkflowUserGroupCode: Code[20]; DueDateFormula: DateFormula)`
- `InsertSalesDocumentCreditLimitApprovalWorkflowSteps(var Workflow: Record Workflow; DocumentType: Enum "Sales Document Type"; ApproverType: Enum "Workflow Approver Type"; LimitType: Enum "Workflow Approver Limit Type"; WorkflowUserGroupCode: Code[20]; DueDateFormula: DateFormula)`
- `InsertEntryPointEventStep(Workflow: Record Workflow; FunctionName: Code[128]): Integer`
- `InsertEventStep(Workflow: Record Workflow; FunctionName: Code[128]; PreviousStepID: Integer): Integer`
- `InsertResponseStep(Workflow: Record Workflow; FunctionName: Code[128]; PreviousStepID: Integer): Integer`
- `InsertStep(var WorkflowStep: Record "Workflow Step"; WorkflowCode: Code[20]; StepType: Option; FunctionName: Code[128])`
- `MarkWorkflowAsTemplate(var Workflow: Record Workflow)`
- `GetSequenceNumber(Workflow: Record Workflow; PreviousStepID: Integer): Integer`
- `SetNextStep(Workflow: Record Workflow; WorkflowStepID: Integer; NextStepID: Integer)`
- `InsertTableRelation(TableId: Integer; FieldId: Integer; RelatedTableId: Integer; RelatedFieldId: Integer)`
- `InsertWorkflowCategory(Code: Code[20]; Description: Text[100])`
- `InsertEventArgument(WorkflowStepID: Integer; EventConditions: Text)`
- `InsertEventRule(WorkflowStepID: Integer; FieldNo: Integer; Operator: Option)`
- `InsertNotificationArgument(WorkflowStepID: Integer; NotifySender: Boolean; NotifUserID: Code[50]; LinkTargetPage: Integer; CustomLink: Text[250])`
- `InsertPmtLineCreationArgument(WorkflowStepID: Integer; GenJnlTemplateName: Code[10]; GenJnlBatchName: Code[10])`
- `InsertApprovalArgument(WorkflowStepID: Integer; ApproverType: Enum "Workflow Approver Type"; ApproverLimitType: Enum "Workflow Approver Limit Type"; WorkflowUserGroupCode: Code[20]; ApproverId: Code[50]; DueDateFormula: DateFormula; ShowConfirmationMessage: Boolean)`
- `InsertMessageArgument(WorkflowStepID: Integer; Message: Text[250])`
- `InsertStepArgument(var WorkflowStepArgument: Record "Workflow Step Argument"; WorkflowStepID: Integer)`
- `GetWorkflowTemplateCode(WorkflowCode: Code[17]): Code[20]`
- `GetWorkflowTemplateToken(): Code[3]`
- `GetWorkflowWizardCode(WorkflowCode: Code[17]): Code[20]`
- `GetWorkflowWizardToken(): Code[3]`
- `SetTemplateForWorkflowStep(Workflow: Record Workflow; FunctionName: Code[128])`
- `SetCustomTemplateToken(NewCustomTemplateToken: Code[3])`
- `InitWorkflowStepArgument(var WorkflowStepArgument: Record "Workflow Step Argument"; ApproverType: Enum "Workflow Approver Type"; ApproverLimitType: Enum "Workflow Approver Limit Type"; ApprovalEntriesPage: Integer; WorkflowUserGroupCode: Code[20]; DueDateFormula: DateFormula; ShowConfirmationMessage: Boolean)`
- `BuildNoPendingApprovalsConditions(): Text`
- `BuildPendingApprovalsConditions(): Text`
- `BuildIncomingDocumentTypeConditions(Status: Option): Text` (obsolete 28.0: Replaced by procedure BuildIncomingDocumentStatusConditions())
- `BuildIncomingDocumentStatusConditions(Status: Enum "Incoming Document Status"): Text`
- `BuildIncomingDocumentOCRTypeConditions(OCRStatus: Option): Text`
- `BuildPurchHeaderTypeConditionsText(DocumentType: Enum "Purchase Document Type"; Status: Enum "Purchase Document Status"): Text`
- `BuildSalesHeaderTypeConditionsText(DocumentType: Enum "Sales Document Type"; Status: Enum "Sales Document Status"): Text`
- `BuildCustomerTypeConditions(): Text`
- `BuildVendorBankTypeConditions(): Text`
- `BuildVendorTypeConditions(): Text`
- `BuildItemTypeConditions(): Text`
- `BuildGeneralJournalBatchTypeConditionsFromRec(var GenJournalBatch: Record "Gen. Journal Batch"): Text`
- `BuildGeneralJournalLineTypeConditions(var GenJournalLine: Record "Gen. Journal Line"): Text`
- `BuildItemJournalBatchTypeConditionsFromRec(var ItemJournalBatch: Record "Item Journal Batch"): Text`
- `BuildRequisitionWkshNameTypeConditionsFromRec(var RequisitionWkshName: Record "Requisition Wksh. Name"): Text`
- `CreateJobQueueEntry(ObjectTypeToRun: Option; ObjectIdToRun: Integer; JobQueueEntryDescription: Text[250]; NotBefore: DateTime; NoOfMinutesBetweenRuns: Integer)`
- `Encode(Text: Text): Text`
- `GetGeneralJournalBatchIsNotBalancedMsg(): Text[250]`

Plus 74 local procedures.

## Triggers

OnRun

## Calls

From the extracted call graph of BC29 (graphify-al on the snapshot checkout): calls whose target is known from a declared type or an `Object::"Name"` argument. Interface dispatch and calls through events are not counted, so the list is not complete.

- [Codeunit 1521 "Workflow Response Handling"](../codeunit/1521.md) (100 calls: `InitWorkflow → CreateResponsesLibrary`, `InsertCustomerApprovalWorkflowDetails → CreateApprovalRequestsCode`, `InsertCustomerApprovalWorkflowDetails → SendApprovalRequestForApprovalCode`, …)
- [Codeunit 1520 "Workflow Event Handling"](../codeunit/1520.md) (98 calls: `InitWorkflow → CreateEventsLibrary`, `InsertCustomerApprovalWorkflowDetails → RunWorkflowOnCancelCustomerApprovalRequestCode`, `InsertCustomerApprovalWorkflowDetails → RunWorkflowOnSendCustomerForApprovalCode`, …)
- [Codeunit 1522 "Workflow Request Page Handling"](../codeunit/1522.md) (2 calls: `InitWorkflow → AssignEntitiesToWorkflowEvents`, `InitWorkflow → CreateEntitiesAndFields`)
- [Codeunit 453 "Job Queue - Enqueue"](../codeunit/453.md) (1 call: `CreateJobQueueEntry → (object)`)
- [Codeunit 6224 "XML DOM Management"](../codeunit/6224.md) (1 call: `Encode → XMLEscape`)

## Called by

- [Codeunit 1804 "Approval Workflow Setup Mgt."](../codeunit/1804.md) (20 calls: `ApplyCustomerWizardUserInput → BuildCustomerTypeConditions`, `ApplyCustomerWizardUserInput → CustomerCreditLimitChangeApprovalWorkflowCode`, `ApplyCustomerWizardUserInput → CustomerWorkflowCode`, …)
- [Codeunit 6280 "Sust. Workflow Event Handling"](../codeunit/6280.md) (18 calls: `AddWorkflowTableRelationsToLibrary → InsertTableRelation`, `BuildSustJournalBatchTypeConditionsFromRec → Encode`, `InsertSustJnlBatchApprovalWorkflowSteps → BuildNoPendingApprovalsConditions`, …)
- [Page 1804 "Approval Workflow Setup Wizard"](../page/1804.md) (3 calls: `SetDefaultValues → GetWorkflowWizardCode`, `SetDefaultValues → PurchaseInvoiceApprovalWorkflowCode`, `SetDefaultValues → SalesInvoiceApprovalWorkflowCode`)
- [Codeunit 1540 "Workflow Webhook Setup"](../codeunit/1540.md) (2 calls: `CreateGeneralJournalBatchApprovalWorkflowSteps → GetGeneralJournalBatchIsNotBalancedMsg`, `InitializeWorkflow → InitWorkflow`)
- [Page 1812 "Item Approval WF Setup Wizard"](../page/1812.md) (2 calls: `SetDefaultValues → GetWorkflowTemplateCode`, `SetDefaultValues → ItemUnitPriceChangeApprovalWorkflowCode`)
- [Page 1813 "Cust. Approval WF Setup Wizard"](../page/1813.md) (2 calls: `SetDefaultValues → CustomerCreditLimitChangeApprovalWorkflowCode`, `SetDefaultValues → GetWorkflowTemplateCode`)
- [Table 1501 "Workflow"](../table/1501.md) (2 calls: `CanDelete → OnAllowEditOfWorkflowTemplates`, `CheckEditingIsAllowed → OnAllowEditOfWorkflowTemplates`)
- [Codeunit 104056 "Upgrade Workflow"](../codeunit/104056.md) (1 call: `UpdateWorkflowWithDelegatedAdminTemplate → ResetWorkflowTemplates`)
- [Codeunit 1541 "Workflow Webhook Events"](../codeunit/1541.md) (1 call: `AddWorkflowWebhookTableRelationsToLibrary → InsertTableRelation`)
- [Codeunit 2 "Company-Initialize"](../codeunit/2.md) (1 call: `OnRun → InitWorkflow`)
- [Codeunit 20423 "Qlty. Workflow Setup"](../codeunit/20423.md) (1 call: `AddEmployeeUserRelationships → InsertTableRelation`)
- [Page 1500 "Workflows"](../page/1500.md) (1 call: `OnOpenPage → InitWorkflow`)
- [Page 1505 "Workflow Templates"](../page/1505.md) (1 call: `Initialize → InitWorkflow`)

## Recent changes

- 2026-07-27 [#9601 Reset workflow templates no longer removes steps from active workflows](../../changes/bcapps/9601.md) (main, BC30, fix)

## Across versions

- Present in: BC23-30
- Changed (declaration) in: BC24, BC28-29

## Deprecations

- procedure BuildIncomingDocumentTypeConditions: Pending 28.0 (#if not CLEAN28), "Replaced by procedure BuildIncomingDocumentStatusConditions()"

Source: AL metadata extracted from the code (names, ids, signatures, properties); no code bodies (D10).

## Ask your agent

Procedure bodies are not stored here (D10). The call sections above are our own, per object, from the BC29 call graph. For a procedure body or the calls of one procedure, ask bc-code-atlas (external, by Stefan Maron, MIT; default corpus w1-28), which the bc-observatory plugin connects: `bcatlas_resolve_node(object_type: "codeunit", object_name: "Workflow Setup")`, then `bcatlas_get_procedure_body` or `bcatlas_get_neighbors` on the returned id.
