---
title: "Codeunit 5051 SegManagement"
author: "Jonas Paprotka"
url: https://jonas-paprotka.de/ref/codeunit/5051-segmanagement/
type: codeunit
id: 5051
name: "SegManagement"
app: "Base Application"
namespace: Microsoft.CRM.Segment
versions: "17-28"
build: 28.5.54151.54365
source: "https://jonas-paprotka.de/ref/codeunit/5051-segmanagement/source/29/"
checked: 2026-09-20
subject: "Microsoft Dynamics 365 Business Central"
license: "Content © 2026 Jonas Paprotka. Quote freely with attribution and a link."
---

# Codeunit 5051 SegManagement

Jonas Paprotka, https://jonas-paprotka.de/ref/codeunit/5051-segmanagement/

| | |
| --- | --- |
| App | Base Application |
| Namespace | Microsoft.CRM.Segment |
| Versions | 17-28 |
| Source file | CRM/Segment/SegManagement.Codeunit.al |

## Procedures

| Name | Parameters | Returns | Access | Versions | Obsolete | Reason |
| --- | --- | --- | --- | --- | --- | --- |
| LogSegment | (Record Segment Header, Boolean, Boolean) | - | public | 17-28 | - | - |
| LogInteraction | (Record Segment Line, var Record Attachment, var Record Inter. Log Entry Comment Line, Boolean, Boolean) | Integer | public | 17-28 | - | - |
| LogDocument | (Integer, Code[20], Integer, Integer, Integer, Code[20], Code[20], Code[20], Text[100], Code[20]) | Integer | public | 17-28 | - | - |
| UnwrapAttachmentCustomLayout | (var Record Segment Line) | - | internal | 17-28 | - | - |
| FindInteractTmplCode | (Integer) | Code[10] | public | 17-24 | Pending 22.0 | Use FindInteractionTemplateCode(DocumentType: Enum "Interaction Log Entry Document Type") instead. |
| CreateCampaignEntryOnSalesInvoicePosting | (Record Sales Invoice Header) | - | public | 17-28 | - | - |
| SalesOrderConfirmInterDocType | () | Integer | public | 17-23 | Pending 22.0 | Replaced by enum "Interaction Log Entry Document Type"::"Sales Ord. Cnfrmn." |
| SalesInvoiceInterDocType | () | Integer | public | 17-23 | Pending 22.0 | Replaced by enum "Interaction Log Entry Document Type"::"Sales Inv." |
| CopyFieldsToCampaignEntry | (var Record Campaign Entry, var Record Segment Line) | - | public | 20-28 | - | - |
| CheckSegmentLine | (var Record Segment Line, Boolean) | - | public | 21-28 | - | - |
| FindInteractionTemplateCode | (Enum Interaction Log Entry Document Type) | Code[10] | public | 22-28 | - | - |
| InterLogEntryCommentLineInsert | (var Record Inter. Log Entry Comment Line, Integer) | - | public | 24-28 | - | - |

## Events

| Kind | Name | Parameters | Versions | Obsolete | Reason |
| --- | --- | --- | --- | --- | --- |
| Integration event | OnAfterFindInteractTmplCode | (Integer, Record Interaction Template Setup, var Code[10]) | 17-24 | Pending 22.0 | Replaed by event OnAfterFindInteractTemplateCode with enum parameter. |
| Integration event | OnAfterFindInteractTmplSetupCaption | (Integer, Record Interaction Template Setup, var Text[80]) | 17-28 | - | - |
| Integration event | OnAfterInsertFollowUpSegment | (var Record Segment Header, Record Logged Segment) | 17-28 | - | - |
| Integration event | OnAfterHandleAttachmentFile | (var Record Segment Line, Record Attachment, Boolean) | 17-28 | - | - |
| Integration event | OnAfterLogInteraction | (var Record Segment Line, var Record Interaction Log Entry) | 17-18 | - | - |
| Integration event | OnAfterLogSegment | (var Record Delivery Sorter, var Record Logged Segment, Record Segment Header, Code[20], Integer) | 17-28 | - | - |
| Integration event | OnBeforeAttachmentInsert | (Record Segment Line, var Record Attachment, var Record Attachment) | 17-28 | - | - |
| Integration event | OnBeforeCampaignEntryNoModify | (var Record Segment Line) | 17-28 | - | - |
| Integration event | OnBeforeDeliverySorterInsert | (var Record Delivery Sorter, Record Segment Line) | 17-28 | - | - |
| Integration event | OnBeforeInteractLogEntryInsert | (var Record Interaction Log Entry, Record Segment Line) | 17-28 | - | - |
| Integration event | OnBeforeLogInteraction | (var Record Segment Line, var Record Attachment, var Record Inter. Log Entry Comment Line, Boolean, Boolean) | 17-19 | - | - |
| Integration event | OnBeforeLogSegment | (Record Segment Header, Boolean, Boolean) | 17-28 | - | - |
| Integration event | OnBeforeLoggedSegmentInsert | (var Record Logged Segment) | 17-28 | - | - |
| Integration event | OnBeforeTempSegmentLineInsert | (var Record Segment Line) | 17-28 | - | - |
| Integration event | OnLogInteractionOnBeforeInteractionLogEntryInsert | (var Record Interaction Log Entry) | 17-19 | - | - |
| Integration event | OnLogInteractionOnBeforeInteractionLogEntryModify | (var Record Interaction Log Entry) | 17-28 | - | - |
| Integration event | OnLogInteractionOnBeforeInterLogEntryCommentLineInsert | (var Record Inter. Log Entry Comment Line) | 17-28 | - | - |
| Integration event | OnLogInteractionOnBeforeTempDeliverySorterInsert | (var Record Delivery Sorter) | 17-18 | - | - |
| Integration event | OnLogSegmentOnAfterCreateInteractionLogEntries | (var Record Segment Header, var Record Logged Segment) | 17-28 | - | - |
| Integration event | OnTestFieldsOnSegmentLineCorrespondenceTypeCaseElse | (var Record Segment Line, Record Contact) | 17-28 | - | - |
| Integration event | OnLogSegmentOnAfterLoggedSegmentInsert | (var Record Logged Segment, Record Segment Header) | 17-28 | - | - |
| Integration event | OnLogSegmentOnAfterInteractLogEntryInsert | (var Record Interaction Log Entry, Record Segment Line) | 17-28 | - | - |
| Integration event | OnLogSegmentOnBeforeFollowupSegmentHeaderInsert | (var Record Segment Header, Record Logged Segment) | 17-28 | - | - |
| Integration event | OnAfterLogInteraction | (var Record Segment Line, var Record Interaction Log Entry, Boolean, Boolean) | 19-28 | - | - |
| Integration event | OnBeforeAssignCorrespondenceTypeForEmail | (var Record Segment Line, Record Contact, Record Contact Alt. Address, var Boolean) | 19-28 | - | - |
| Integration event | OnBeforeTestFieldsFromLogInteraction | (var Record Segment Line, Boolean, Boolean, var Boolean) | 19-28 | - | - |
| Integration event | OnLogDocumentOnCaseElse | (Integer, Code[20], var Code[20]) | 19-28 | - | - |
| Integration event | OnLogInteractionOnBeforeTempDeliverySorterInsert | (var Record Delivery Sorter, Record Segment Line, Record Interaction Log Entry) | 19-28 | - | - |
| Integration event | OnLogSegmentOnAfterCalcShowIsNotEmptyError | (var Record Logged Segment, Boolean, var Boolean) | 19-28 | - | - |
| Integration event | OnLogSegmentOnAfterCalcShouldModifyAttachment | (var Record Attachment, Record Segment Line, Record Segment Header, var Boolean) | 19-28 | - | - |
| Integration event | OnBeforeCheckSalesperson | (var Record Segment Line, var Boolean) | 20-28 | - | - |
| Integration event | OnBeforeLogInteraction | (var Record Segment Line, var Record Attachment, var Record Inter. Log Entry Comment Line, var Boolean, var Boolean) | 20-28 | - | - |
| Integration event | OnLogDocumentOnAfterFindInteractTmplCode | (var Code[10], var Record Attachment, Integer) | 20-28 | - | - |
| Integration event | OnLogDocumentOnBeforeTempSegmentLineModify | (var Record Segment Line, Integer, Code[20]) | 20-28 | - | - |
| Integration event | OnLogInteractionOnBeforeInteractionLogEntryInsert | (var Record Interaction Log Entry, Record Attachment, Record Segment Line) | 20-28 | - | - |
| Integration event | OnLogInteractionOnAfterGetInteractLogEntryFromSegmentLine | (var Record Interaction Log Entry, Record Segment Line, Boolean) | 20-28 | - | - |
| Integration event | OnAfterFindInteractTemplateCode | (Enum Interaction Log Entry Document Type, Record Interaction Template Setup, var Code[10]) | 22-28 | - | - |
| Integration event | OnLogDocumentOnBeforeTempSegmentLineInit | (Integer, Code[20], var Code[20], var Integer, var Boolean) | 23-28 | - | - |
| Integration event | OnLogInteractionOnBeforeCheckAttachmentFileValue | (Record Segment Line, var Record Attachment, var Record Inter. Log Entry Comment Line, Boolean, Boolean, var Integer, var Boolean) | 23-28 | - | - |
| Integration event | OnLogSegmentOnBeforeInitLoggedSegment | (Record Segment Header, Boolean, Boolean, var Boolean) | 23-28 | - | - |
| Integration event | OnBeforeCheckSegmentLine | (var Record Segment Line, Boolean, var Boolean) | 24-28 | - | - |
| Integration event | OnLogDocumentOnBeforeTestTmplLanguage | (Code[10], var Boolean) | 24-28 | - | - |
| Integration event | OnAfterCopyFieldsToCampaignEntry | (var Record Campaign Entry, var Record Segment Line) | 24-28 | - | - |
| Integration event | OnLogInteractionOnAfterInterLogEntryCommentLineInsert | (var Record Inter. Log Entry Comment Line, Record Segment Line, Integer) | 24-28 | - | - |
| Integration event | OnLogInteractionOnBeforeInteractLogEntryGet | (var Integer, Record Segment Line, Boolean, var Boolean) | 24-28 | - | - |
| Integration event | OnLogInteractionOnBeforeWizSaveAttachment | (Record Segment Line, var Record Attachment, var Record Attachment) | 25-28 | - | - |
| Integration event | OnBeforeExportAttachmentFile | (var Record Segment Line, Record Attachment, var Record Attachment, var Boolean, var Boolean) | 25-28 | - | - |

## Source

Symbols: Microsoft.BaseApplication.symbols.437dbf0e-84ff-417a-965d-ed2bb9650972, https://dynamicssmb2.pkgs.visualstudio.com/DynamicsBCPublicFeeds/_packaging/MSSymbols/nuget/v3/index.json, highest build per major on 2026-09-20.
AL source 29: https://github.com/microsoft/BCApps, MIT, releases/29.x at a66254c3b8b5bb1cea290dc8f9d097aec4381153.

Jonas Paprotka, 2026-09-20.
