---
id: object/codeunit/28
type: object
title: Codeunit 28 "Error Message Management"
summary: Codeunit 28 "Error Message Management" in Base Application (System.Utilities). 45 public procedures, 17 events. Present since at least BC23, still in BC30, changed in BC24-27.
tier: official
language: en
tags:
  - codeunit
  - base application
versions:
  introduced: null
  last_changed: "27"
  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: e591273f7fa5f81ab6d08a69cb163ee87262d2c0cdac09b1fc853a53da4d2ed4
evidence:
  - kind: code
    url: https://github.com/microsoft/BCApps/blob/ea08af5ef2d6a9b5c5af4a029288abbe2c883220/src/Layers/W1/BaseApp/Modules/System/ErrorMessage/ErrorMessageManagement.Codeunit.al
    title: src/Layers/W1/BaseApp/Modules/System/ErrorMessage/ErrorMessageManagement.Codeunit.al (releases/29.x)
    date: null
    commit: ea08af5ef2d6a9b5c5af4a029288abbe2c883220
    t: null
    quote: null
links:
  learn: []
  objects: []
  features: []
  topics: []
  localizations: []
  videos: []
  posts: []
  guidelines: []
object_type: codeunit
object_id: 28
name: Error Message Management
namespace: System.Utilities
app: Base Application
extends: null
first_version: "23"
last_version: "30"
present_in:
  - "23"
  - "24"
  - "25"
  - "26"
  - "27"
  - "28"
  - "29"
  - "30"
changed_in:
  - "24"
  - "25"
  - "26"
  - "27"
source_major: "29"
obsolete: null
countries: []
ms_search_form_ids: []
counts:
  fields: 0
  procedures: 75
  events: 17
  subscribers: 0
relations:
  out: 0
  referenced_by: 0
  pages: 0
  extended_by: 0
  event_subscribers: 18
  calls: 2
  called_by: 65
  implements: 0
---

# Codeunit 28 "Error Message Management"

> Codeunit 28 "Error Message Management" in Base Application (System.Utilities). 45 public procedures, 17 events. Present since at least BC23, still in BC30, changed in BC24-27.

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

## Events published

- `OnFindActiveSubscriber(var IsFound: Boolean)` (integration)
  - subscribers: [Codeunit 29 "Error Message Handler"](../codeunit/29.md) OnFindActiveSubscriberHandler
- `OnGetFirstContextID(ContextRecordID: RecordID; var ContextID: Integer)` (integration)
  - subscribers: [Codeunit 29 "Error Message Handler"](../codeunit/29.md) OnGetFirstContextIDHandler
- `OnGetErrors(var TempErrorMessageResult: Record "Error Message" temporary)` (integration)
  - subscribers: [Codeunit 29 "Error Message Handler"](../codeunit/29.md) OnGetErrorsHandler
- `OnGetLastErrorID(var ID: Integer; var ErrorMessage: Text[250])` (integration)
  - subscribers: [Codeunit 29 "Error Message Handler"](../codeunit/29.md) OnGetLastErrorID
- `OnGetCachedLastErrorID(var ID: Integer)` (integration)
  - subscribers: [Codeunit 29 "Error Message Handler"](../codeunit/29.md) OnGetCachedLastErrorID
- `OnGetLastErrorMessageRecord(var ErrorMessage: Record "Error Message" temporary)` (internal)
  - subscribers: [Codeunit 29 "Error Message Handler"](../codeunit/29.md) OnGetLastErrorMessageRecord
- `OnLogSimpleError(ErrorMessage: Text; var IsLogged: Boolean)` (integration)
  - subscribers: [Codeunit 29 "Error Message Handler"](../codeunit/29.md) OnLogSimpleErrorHandler
- `OnLogError(MessageType: Option; ContextFieldNo: Integer; ErrorMessage: Text; SourceVariant: Variant; SourceFieldNo: Integer; HelpArticleCode: Code[30]; var IsLogged: Boolean)` (integration)
  - subscribers: [Codeunit 29 "Error Message Handler"](../codeunit/29.md) OnLogErrorHandler
- `OnPushContext()` (integration)
  - subscribers: [Codeunit 29 "Error Message Handler"](../codeunit/29.md) OnPushContextHandler
- `OnGetTopElement(var TopElementID: Integer)` (integration)
  - subscribers: [Codeunit 30 "Error Context Element"](../codeunit/30.md) OnGetTopElementHandler
- `OnGetTopElementData(var TopElementID: Integer; var ContextRecID: RecordID; var ContextFldNo: Integer; var AdditionalInfo: Text[250])` (integration)
  - subscribers: [Codeunit 30 "Error Context Element"](../codeunit/30.md) OnGetTopElementDataHandler
- `OnGetTopContext(var ErrorMessage: Record "Error Message")` (integration)
  - subscribers: [Codeunit 30 "Error Context Element"](../codeunit/30.md) OnGetTopContextHandler
- `OnLogLastError()` (integration)
  - subscribers: [Codeunit 29 "Error Message Handler"](../codeunit/29.md) OnLogLastErrorHandler
- `OnBeforeGetContextRecID(ContextVariant: Variant; var ContextRecID: RecordID; var IsHandled: Boolean)` (integration)
- `OnAddToJsonFromErrorMessage(var JObject: JsonObject; var ErrorMessage: Record "Error Message" temporary)` (integration)
  - subscribers: [Codeunit 7905 "ErrorMessagesActionHandlerImpl"](../codeunit/7905.md) OnAddToJsonFromErrorMessageHandler
- `OnAddToErrorMessageFromJson(var ErrorMessage: Record "Error Message" temporary; var JObject: JsonObject)` (integration)
  - subscribers: [Codeunit 7905 "ErrorMessagesActionHandlerImpl"](../codeunit/7905.md) OnAddToErrorMessageFromJsonHandler
- `OnAddSubContextToLastErrorMessage(Tag: Text; VariantRec: Variant; var ErrorMessage: Record "Error Message" temporary)` (integration)
  - subscribers: [Codeunit 7903 "Dimension Code Same Error"](../codeunit/7903.md) OnAddSubContextToLastErrorMessage, [Codeunit 7904 "Dimension Code Must Be Blank"](../codeunit/7904.md) OnAddSubContextToLastErrorMessage, [Codeunit 7906 "Dim. Code Same But Missing Err"](../codeunit/7906.md) OnAddSubContextToLastErrorMessage

## Procedures

- `Activate(var ErrorMessageHandler: Codeunit "Error Message Handler"): Boolean`
- `Activate(var ErrorMessageHandler: Codeunit "Error Message Handler"; ClearError: Boolean): Boolean`
- `IsActive(): Boolean`
- `Finish(ContextVariant: Variant)`
- `FinishTopContext()`
- `IsTransactionStopped(): Boolean`
- `GetCurrCallStack(): Text`
- `ShowErrors(Notification: Notification)`
- `ShowErrors(RegisterID: Guid)`
- `ThrowError(ContextErrorMessage: Text; DetailedErrorMessage: Text)`
- `GetFieldNo(TableNo: Integer; FieldName: Text): Integer`
- `FindFirstErrorMessage(var ErrorMessage: Text[250]): Boolean`
- `GetErrors(var TempErrorMessage: Record "Error Message" temporary): Boolean`
- `GetErrorsInContext(ContextVariant: Variant; var TempErrorMessage: Record "Error Message" temporary): Boolean`
- `GetLastError(var ErrorMessage: Text[250]): Integer`
- `GetLastErrorID(): Integer`
- `GetCachedLastErrorID(): Integer`
- `LogError(SourceVariant: Variant; ErrorMessage: Text; HelpArticleCode: Code[30])`
- `LogContextFieldError(ContextFieldNo: Integer; ErrorMessage: Text; SourceVariant: Variant; SourceFieldNo: Integer; HelpArticleCode: Code[30])`
- `LogMessage(NewMessageType: Option; ContextFieldNo: Integer; InformationMessage: Text; SourceVariant: Variant; SourceFieldNo: Integer; HelpArticleCode: Code[30]): Boolean`
- `LogErrorMessage(ContextFieldNo: Integer; ErrorMessage: Text; SourceVariant: Variant; SourceFieldNo: Integer; HelpArticleCode: Code[30]): Boolean`
- `LogSimpleErrorMessage(ErrorMessage: Text): Boolean`
- `LogTestField(SourceVariant: Variant; SourceFieldNo: Integer): Boolean`
- `LogTestField(SourceVariant: Variant; SourceFieldNo: Integer; ExpectedValue: Variant): Boolean`
- `LogFieldError(SourceVariant: Variant; SourceFieldNo: Integer; ErrorMessage: Text): Boolean`
- `InsertTempLineErrorMessage(var TempLineErrorMessage: Record "Error Message" temporary; RecordId: RecordId; TableNo: Integer; FieldNo: Integer; Description: Text; CallStack: Text)`
- `CollectErrors(var TempLineErrorMessage: Record "Error Message" temporary)`
- `LogLastError()`
- `FldRefHasValue(FldRef: FieldRef): Boolean`
- `GetErrorsFromResultValues(Values: List of [Text]; var TempErrorMessage: Record "Error Message" temporary)`
- `AddSubContextToLastErrorMessage(Tag: Text; VariantRec: Variant)`
- `ParseErrorText(JSON: Text; var TempErrorMessage: Record "Error Message" temporary)`
- `ErrorMessage2JSON(var ErrorMessage: Record "Error Message"): Text`
- `PackErrorMessagesToResults(var TempErrorMessage: Record "Error Message" temporary; var Results: Dictionary of [Text, Text])`
- `LogWarning(ContextFieldNo: Integer; WarningMessage: Text; SourceVariant: Variant; SourceFieldNo: Integer; HelpArticleCode: Code[30]): Boolean`
- `LogWarning(WarningMessage: Text): Boolean`
- `LogInformation(ContextFieldNo: Integer; InformationMessage: Text; SourceVariant: Variant; SourceFieldNo: Integer; HelpArticleCode: Code[30]): Boolean`
- `LogInformation(InformationMessage: Text): Boolean`
- `PopContext(var ErrorContextElement: Codeunit "Error Context Element"): Integer`
- `PushContext(var ErrorContextElement: Codeunit "Error Context Element"; ContextVariant: Variant; ContextFieldNo: Integer; AdditionalInfo: Text[250]): Integer`
- `GetLastContext(var ErrorMessage: Record "Error Message"): Boolean`
- `BuildActionableErrorInfo(ErrorTitle: Text; ErrorMessage: Text; RecId: RecordId; ActionMessage: Text; ActionCodeunuitId: Integer; ActionName: Text): ErrorInfo`
- `BuildActionableErrorInfo(ErrorTitle: Text; ErrorMessage: Text; RecId: RecordId; ActionMessage: Text; ActionCodeunuitId: Integer; ActionName: Text; ActionDescription: Text): ErrorInfo`
- `BuildActionableErrorInfo(ErrorTitle: Text; ErrorMessage: Text; SysId: Guid; ActionMessage: Text; ActionCodeunuitId: Integer; ActionName: Text; ActionDescription: Text): ErrorInfo`
- `GetTopContext(var ErrorMessage: Record "Error Message"): Boolean`

Plus 13 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 31 "Last Error Context Element"](../codeunit/31.md) (3 calls: `GetLastContext → GetErrorMessage`, `PopContext → Set`, `PushContext → Set`)
- [Codeunit 30 "Error Context Element"](../codeunit/30.md) (2 calls: `PushContext → GetID`, `PushContext → Set`)

## Called by

- [Codeunit 481 "Check Dimensions"](../codeunit/481.md) (24 calls: `CheckPurchDimCombHeader → PopContext`, `CheckPurchDimCombHeader → PushContext`, `CheckPurchDimCombHeader → ThrowError`, …)
- [Codeunit 80 "Sales-Post"](../codeunit/80.md) (12 calls: `CheckBlockedPostingGroups → LogContextFieldError`, `CheckSalesDocument → Finish`, `CheckSalesDocument → GetFieldNo`, …)
- [Codeunit 90 "Purch.-Post"](../codeunit/90.md) (12 calls: `CheckBlockedPostingGroups → LogContextFieldError`, `CheckPostingDate → GetFieldNo`, `CheckPostingDate → LogContextFieldError`, …)
- [Codeunit 442 "Sales-Post Prepayments"](../codeunit/442.md) (11 calls: `BuildInvLineBuffer → FinishTopContext`, `CheckPrepmtDoc → Finish`, `CheckPrepmtDoc → GetFieldNo`, …)
- [Codeunit 444 "Purchase-Post Prepayments"](../codeunit/444.md) (11 calls: `BuildInvLineBuffer → FinishTopContext`, `CheckPrepmtDoc → Finish`, `CheckPrepmtDoc → GetFieldNo`, …)
- [Codeunit 408 "DimensionManagement"](../codeunit/408.md) (9 calls: `FindLastErrorMessage → GetLastError`, `FindLastErrorMessage → IsActive`, `GetLastDimErrorID → GetCachedLastErrorID`, …)
- [Codeunit 9068 "Check Purch. Doc. Backgr."](../codeunit/9068.md) (9 calls: `OnRun → PackErrorMessagesToResults`, `RunPurchaseDocCheckCodeunit → Activate`, `RunPurchaseDocCheckCodeunit → CollectErrors`, …)
- [Codeunit 9072 "Check Sales Doc. Backgr."](../codeunit/9072.md) (9 calls: `OnRun → PackErrorMessagesToResults`, `RunSalesDocCheckCodeunit → Activate`, `RunSalesDocCheckCodeunit → CollectErrors`, …)
- [Codeunit 13 "Gen. Jnl.-Post Batch"](../codeunit/13.md) (7 calls: `CheckLine → PopContext`, `CheckLine → PushContext`, `CheckShortcutDimConsistency → Finish`, …)
- [Codeunit 1380 "Batch Processing Mgt."](../codeunit/1380.md) (6 calls: `BatchProcessGenJournalLine → Activate`, `CanProcessRecord → LogError`, `GetErrorMessages → GetErrors`, …)
- [Codeunit 1509 "Notification Entry Dispatcher"](../codeunit/1509.md) (6 calls: `AddNote → LogError`, `CreateMailAndDispatch → LogError`, `DispatchInstantNotifications → Activate`, …)
- [Codeunit 6620 "Copy Document Mgt."](../codeunit/6620.md) (6 calls: `CopySalesDoc → Activate`, `CopySalesDoc → PopContext`, `CopySalesDoc → PushContext`, …)
- [Codeunit 9079 "Background Error Handling Mgt."](../codeunit/9079.md) (5 calls: `GetErrorsFromDocumentCheckResultValues → GetErrorsFromResultValues`, `GetErrorsFromGenJnlCheckResultValues → GetErrorsFromResultValues`, `GetErrorsFromItemJnlCheckResultValues → GetErrorsFromResultValues`, …)
- [Codeunit 9084 "Check Service Doc. Backgr."](../codeunit/9084.md) (5 calls: `OnRun → PackErrorMessagesToResults`, `RunServiceDocCheckCodeunit → Activate`, `RunServiceDocCheckCodeunit → CollectErrors`, …)
- [Codeunit 1371 "Sales Batch Post Mgt."](../codeunit/1371.md) (4 calls: `PrepareBatch → LogError`, `RunWithUI → Activate`, `RunWithUI → GetLastErrorID`, …)
- [Codeunit 1372 "Purchase Batch Post Mgt."](../codeunit/1372.md) (4 calls: `PrepareBatch → LogError`, `RunWithUI → Activate`, `RunWithUI → GetLastErrorID`, …)
- [Codeunit 5286 "Data Check Mgt. SAF-T"](../codeunit/5286.md) (4 calls: `LogError → LogContextFieldError`, `OnRun → Activate`, `OnRun → PushContext`, …)
- [Codeunit 8800 "Custom Layout Reporting"](../codeunit/8800.md) (4 calls: `LogErrorEmailSendTo → LogError`, `LogSimpleError → LogSimpleErrorMessage`, `ProcessReport → Activate`, …)
- [Codeunit 8811 "Customer Statement via Queue"](../codeunit/8811.md) (4 calls: `OnRun → Activate`, `OnRun → LogErrorMessage`, `OnRun → PopContext`, …)
- [Codeunit 11 "Gen. Jnl.-Check Line"](../codeunit/11.md) (3 calls: `RunCheck → Activate`, `RunCheck → GetErrors`, `RunCheck → PushContext`)
- [Codeunit 19 "Gen. Jnl.-Post Preview"](../codeunit/19.md) (3 calls: `OnRun → LogError`, `PreviewStart → Activate`, `PreviewStart → PushContext`)
- [Codeunit 373 "Bank. Acc. Recon. Post Preview"](../codeunit/373.md) (3 calls: `PreviewStart → Activate`, `PreviewStart → PushContext`, `RunPreview → LogError`)
- [Codeunit 393 "Reminder-Issue"](../codeunit/393.md) (3 calls: `OnRun → Activate`, `OnRun → PopContext`, `OnRun → PushContext`)
- [Codeunit 449 "Job Queue Start Codeunit"](../codeunit/449.md) (3 calls: `OnRun → GetErrorsInContext`, `OnRun → PopContext`, `OnRun → PushContext`)
- [Codeunit 450 "Job Queue Error Handler"](../codeunit/450.md) (3 calls: `LogError → Activate`, `LogError → PopContext`, `LogError → PushContext`)
- [Codeunit 5988 "Serv-Documents Mgt."](../codeunit/5988.md) (3 calls: `PostDocumentLines → Finish`, `PostDocumentLines → PopContext`, `PostDocumentLines → PushContext`)
- [Codeunit 7092 "Expense Report Batch Post Mgt."](../codeunit/7092.md) (3 calls: `RunWithUI → Activate`, `RunWithUI → GetLastErrorID`, `RunWithUI → PushContext`)
- [Report 5707 "Batch Post Transfer Orders"](../report/5707.md) (3 calls: `RunPostBatchTransferOrder → Activate`, `RunPostBatchTransferOrder → LogErrorMessage`, `RunPostBatchTransferOrder → PushContext`)
- [Codeunit 1000 "Job Calculate WIP"](../codeunit/1000.md) (2 calls: `ActivateErrorMessageHandling → Activate`, `ActivateErrorMessageHandling → PushContext`)
- [Codeunit 20415 "Qlty. Tracking Integration"](../codeunit/20415.md) (2 calls: `LogBlockedTransactionError → IsActive`, `LogBlockedTransactionError → LogContextFieldError`)
- [Codeunit 443 "Sales-Post Prepayment (Yes/No)"](../codeunit/443.md) (2 calls: `PostPrepmtDocument → Activate`, `PostPrepmtDocument → PushContext`)
- [Codeunit 445 "Purch.-Post Prepmt. (Yes/No)"](../codeunit/445.md) (2 calls: `PostPrepmtDocument → Activate`, `PostPrepmtDocument → PushContext`)
- [Codeunit 5261 "Audit File Export Mgt."](../codeunit/5261.md) (2 calls: `PreExportCheck → Activate`, `PreExportCheck → GetLastErrorID`)
- [Codeunit 5285 "Audit Data Check SAF-T"](../codeunit/5285.md) (2 calls: `CheckAuditDocReadyToExport → GetLastErrorID`, `CheckAuditDocReadyToExport → LogErrorMessage`)
- [Codeunit 6216 "Sustainability Jnl.-Check"](../codeunit/6216.md) (2 calls: `CheckSustainabilityJournalLineWithErrorCollect → CollectErrors`, `CheckSustainabilityJournalLineWithErrorCollect → InsertTempLineErrorMessage`)
- [Codeunit 6273 "Sust. Excise Jnl.-Check"](../codeunit/6273.md) (2 calls: `CheckSustainabilityExciseJournalLineWithErrorCollect → CollectErrors`, `CheckSustainabilityExciseJournalLineWithErrorCollect → InsertTempLineErrorMessage`)
- [Codeunit 85 "Sales Post Batch via Job Queue"](../codeunit/85.md) (2 calls: `PostSalesBatch → LogLastError`, `PrintDocument → LogLastError`)
- [Codeunit 9081 "Check Gen. Jnl. Line. Backgr."](../codeunit/9081.md) (2 calls: `PackErrorMessagesToResults → ErrorMessage2JSON`, `RunGenJnlCheckLineCodeunit → CollectErrors`)
- [Codeunit 95 "Purch Post Batch via Job Queue"](../codeunit/95.md) (2 calls: `PostPurchaseBatch → LogLastError`, `PrintDocument → LogLastError`)
- [Table 36 "Sales Header"](../table/36.md) (2 calls: `SendToPosting → Activate`, `SendToPosting → PushContext`)
- [Table 37 "Sales Line"](../table/37.md) (2 calls: `CannotInvoiceErrorInfo → BuildActionableErrorInfo`, `CannotShipErrorInfo → BuildActionableErrorInfo`)
- [Table 38 "Purchase Header"](../table/38.md) (2 calls: `SendToPosting → Activate`, `SendToPosting → PushContext`)
- [Table 39 "Purchase Line"](../table/39.md) (2 calls: `CannotInvoiceErrorInfo → BuildActionableErrorInfo`, `CannotReceiveErrorInfo → BuildActionableErrorInfo`)
- [Table 5740 "Transfer Header"](../table/5740.md) (2 calls: `CheckTransferLines → PopContext`, `CheckTransferLines → PushContext`)
- [Table 5900 "Service Header"](../table/5900.md) (2 calls: `SendToPostWithLines → Activate`, `SendToPostWithLines → PushContext`)
- [Table 700 "Error Message"](../table/700.md) (2 calls: `AssertRecordTemporaryOrInContext → GetTopContext`, `GetContext → GetTopContext`)
- [Codeunit 2580 "Dimension Correction Mgt"](../codeunit/2580.md) (1 call: `ValidateDimensionSets → GetLastError`)
- [Codeunit 48 "PostingSetupManagement"](../codeunit/48.md) (1 call: `LogContextFieldError → LogContextFieldError`)
- [Codeunit 5260 "Audit Mapping Helper"](../codeunit/5260.md) (1 call: `LogError → LogError`)
- [Codeunit 5580 "Voucher Attachment Check"](../codeunit/5580.md) (1 call: `CheckVoucherIsAttachedToDocument → LogSimpleErrorMessage`)
- and 15 more: data/code/graph/29/calls.json

## Across versions

- Present in: BC23-30
- Changed (declaration) in: BC24-27

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: "Error Message Management")`, then `bcatlas_get_procedure_body` or `bcatlas_get_neighbors` on the returned id.
