---
id: object/codeunit/5350
type: object
title: Codeunit 5350 "CRM Statistics Job"
summary: Codeunit 5350 "CRM Statistics Job" in Base Application (Microsoft.Integration.D365Sales). 4 public procedures, 2 events, 2 event subscribers. Present since at least BC23, still in BC30, changed in BC24-25.
tier: official
language: en
tags:
  - codeunit
  - base application
versions:
  introduced: null
  last_changed: "25"
  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: 5573e8432cff3673684b5c9b796017b939fa0f544e5b5958a44c64ca3c49e7c4
evidence:
  - kind: code
    url: https://github.com/microsoft/BCApps/blob/ea08af5ef2d6a9b5c5af4a029288abbe2c883220/src/Layers/W1/BaseApp/Integration/D365Sales/CRMStatisticsJob.Codeunit.al
    title: src/Layers/W1/BaseApp/Integration/D365Sales/CRMStatisticsJob.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: 5350
name: CRM Statistics Job
namespace: Microsoft.Integration.D365Sales
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"
source_major: "29"
obsolete: null
countries: []
ms_search_form_ids: []
counts:
  fields: 0
  procedures: 23
  events: 2
  subscribers: 2
relations:
  out: 1
  referenced_by: 0
  pages: 0
  extended_by: 0
  event_subscribers: 2
  calls: 4
  called_by: 1
  implements: 0
---

# Codeunit 5350 "CRM Statistics Job"

> Codeunit 5350 "CRM Statistics Job" in Base Application (Microsoft.Integration.D365Sales). 4 public procedures, 2 events, 2 event subscribers. Present since at least BC23, still in BC30, changed in BC24-25.

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

## Properties

| Property | Value |
|---|---|
| TableNo | Job Queue Entry |

## Events published

- `OnAfterAddCustomersWithLinesActivity(StartDateTime: DateTime; var CustomerNumbers: List of [Code[20]])` (integration)
  - subscribers: [Codeunit 6450 "Serv. Integration Mgt."](../codeunit/6450.md) OnAfterAddCustomersWithLinesActivity
- `OnCreateOrUpdateCRMAccountStatisticsOnBeforeModify(var CRMAccountStatistics: Record "CRM Account Statistics"; var Customer: Record Customer)` (integration)
  - subscribers: [Codeunit 6450 "Serv. Integration Mgt."](../codeunit/6450.md) OnCreateOrUpdateCRMAccountStatisticsOnBeforeModify

## Event subscriptions

- OnFindingIfJobNeedsToBeRun subscribes to Table "Job Queue Entry" OnFindingIfJobNeedsToBeRun
- DeleteAccountStatisticsOnAfterUncoupleRecord subscribes to Codeunit "Int. Rec. Uncouple Invoke" OnAfterUncoupleRecord

## Procedures

- `CreateOrUpdateCRMAccountStatistics(Customer: Record Customer; var CRMAccount: Record "CRM Account"): Integer`
- `GetAccStatsUpdateFinalMessage(): Text`
- `GetInvStatusUpdateFinalMessage(): Text`
- `UpdateStatusOfPaidInvoices(CustomerNo: Code[20]): Integer`

Plus 15 local procedures.

## Triggers

OnRun

## Relations

- runs on [Table 472 "Job Queue Entry"](../table/472.md)

## 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 5335 "Integration Table Synch."](../codeunit/5335.md) (7 calls: `UpdateAccountStatistics → BeginIntegrationSynchJobLoging`, `UpdateAccountStatistics → EndIntegrationSynchJobWithMsg`, `UpdateAccountStatistics → IncrementSynchJobCounters`, …)
- [Codeunit 5342 "CRM Synch. Helper"](../codeunit/5342.md) (3 calls: `CreateOrUpdateCRMAccountStatistics → FindNAVLocalCurrencyInCRM`, `UpdateInvoice → CancelCRMInvoice`, `UpdateInvoice → UpdateCRMInvoiceStatusFromEntry`)
- [Codeunit 5330 "CRM Integration Management"](../codeunit/5330.md) (2 calls: `InitializeCustomerStatisticsSynchronizationTime → InitializeCRMSynchStatus`, `UpdateStatusOfPaidInvoices → InitializeCRMSynchStatus`)
- [Codeunit 5344 "CRM Product Name"](../codeunit/5344.md) (1 call: `UpdateStatisticsAndInvoices → FULL`)

## Called by

- [Codeunit 5330 "CRM Integration Management"](../codeunit/5330.md) (2 calls: `CreateOrUpdateCRMAccountStatistics → CreateOrUpdateCRMAccountStatistics`, `CreateOrUpdateCRMAccountStatistics → UpdateStatusOfPaidInvoices`)

## Across versions

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

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: "CRM Statistics Job")`, then `bcatlas_get_procedure_body` or `bcatlas_get_neighbors` on the returned id.
