{"title":"ErrorInfo.AddAction(Text, Integer, Text) Method","url":"https://jonas-paprotka.de/docs/dev-itpro/developer/methods-auto/errorinfo/errorinfo-addaction-string-integer-string-method/","by":"JOP-AL","license":"Copyright (c) Microsoft Corporation. CC BY 4.0, https://creativecommons.org/licenses/by/4.0/; code samples MIT. From https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/methods-auto/errorinfo/errorinfo-addaction-string-integer-string-method, MicrosoftDocs/dynamics365smb-devitpro-pb at 828b6ee (2026-11-19). Changed: includes filled in, links to this site, and for agents shortened without dropping a fact.","credit":"Microsoft Corporation, CC BY 4.0","origin":"https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/methods-auto/errorinfo/errorinfo-addaction-string-integer-string-method","source":{"name":"Business Central developer and IT pro docs","repo":"https://github.com/MicrosoftDocs/dynamics365smb-devitpro-pb","commit":"828b6ee72fcd75755627cd6011f3d20899217ab2","date":"2026-11-19"},"checked":"2026-11-19","description":"Specifies an action for the error.","date":"2026-10-01","meta":{"topic":"reference"},"outline":[{"level":1,"title":"ErrorInfo.AddAction(Text, Integer, Text) Method","slug":"errorinfoaddactiontext-integer-text-method","at":0,"chars":3909},{"level":2,"title":"Syntax","slug":"syntax","at":146,"chars":95},{"level":2,"title":"Parameters","slug":"parameters","at":241,"chars":762},{"level":2,"title":"Remarks","slug":"remarks","at":1003,"chars":1098},{"level":2,"title":"Example","slug":"example","at":2101,"chars":1605},{"level":2,"title":"Related information","slug":"related-information","at":3706,"chars":203}],"text":"# ErrorInfo.AddAction(Text, Integer, Text) Method\n> Version: _Available or changed with runtime version 11.0._\nSpecifies an action for the error.\n## Syntax\n```al\n ErrorInfo.AddAction(Caption: Text, CodeunitID: Integer, MethodName: Text)\n```\n## Parameters\nErrorInfo\nType: errorinfo-data-type\nAn instance of the errorinfo-data-type data type.\nCaption\nType: ../text/text-data-type\nThe text string that appears as the caption of the action in the error UI. The string can be a label that is enabled for multilanguage functionality.\nCodeunitID\nType: ../integer/integer-data-type\nThe ID of the Codeunit to run when the action is initiated from the error UI. The codeunit should contain at least one global method to be called by the error action. The global method must have an ErrorInfo data type parameter for accepting the ErrorInfo object.\nMethodName\nType: ../text/text-data-type\nThe name of the method in the Codeunit, which is specified by the CodeunitID parameter, that you want to run for the action.\n## Remarks\nThe AddAction method accepts four parameters:\n Caption, which is the text string that appears as the caption of the action in the error UI.\n CodeunitID, which is the ID of the codeunit to run when the action is initiated from the error UI. The codeunit should contain at least one global method to be called by the error action. The global method must have an ErrorInfo data type parameter for accepting the ErrorInfo object.\n Method Name, which is the name of the method in the codeunit specified by the CodeunitID parameter, that you want to run for the action.\n Tooltip, which is the text string that appears as the tooltip of the action in the error UI.\nIf you call ErrorInfo.AddAction and codeunit exists with the provided CodeunitID or no method called MethodName exists in that codeunit, then a runtime error occurs.\nIf possible, call ErrorInfo.AddAction using Codeunit::CodeunitName and not the literal integer for the object ID of the codeunit. If there is a renumbering of the codeunit or if the codeunit was removed, then you get a compile-time error and not a runtime error.\n## Example\nIn the following example from the Business Central base app, you can see how an error message can be annotated with actions that the user can do to get unblocked.\n```al\n procedure PreventModifyRecIfOpenApprovalEntryExistForCurrentUser(Variant: Variant)\n    var\n        WorkflowWebhookMgt: Codeunit \"Workflow Webhook Management\";\n        RecRef: RecordRef;\n        ErrInfo: ErrorInfo;\n        RejectApprovalRequestLbl: Label 'Reject approval';\n        ShowCommentsLbl: Label 'Show comments';\n        RejectApprovalRequestToolTipLbl: Label 'Reject approval request';\n        ShowCommentsToolTipLbl: Label 'Show approval comments';\n    begin\n        RecRef.GetTable(Variant);\n        if HasOpenApprovalEntriesForCurrentUser(RecRef.RecordId) or WorkflowWebhookMgt.HasPendingWorkflowWebhookEntryByRecordId(RecRef.RecordId) then begin\n            ErrInfo.ErrorType(ErrorType::Client);\n            ErrInfo.Verbosity(Verbosity::Error);\n            ErrInfo.Message(PreventModifyRecordWithOpenApprovalEntryMsg);\n            ErrInfo.TableId(RecRef.Number);\n            ErrInfo.RecordId(RecRef.RecordId);\n            ErrInfo.AddAction(RejectApprovalRequestLbl, Codeunit::\"Approvals Mgmt.\", 'RejectApprovalRequest', RejectApprovalRequestToolTipLbl);\n            ErrInfo.AddAction(ShowCommentsLbl, Codeunit::\"Approvals Mgmt.\", 'ShowApprovalCommentLinesForJournal', ShowCommentsToolTipLbl);\n            Error(ErrInfo);\n        end;\n    end;\n```\nTo see a different code example with an error dialog with a Fix-it action, see Error messages with Show-it actions<../../devenv-actionable-errors#show-it-actions>.\n## Related information\nerrorinfo-data-type\n../../devenv-actionable-errors\n../../devenv-al-error-handling\nGetting Started with AL<../../devenv-get-started>\nDeveloping Extensions<../../devenv-dev-overview>"}