{"title":"Codeunit 5350 CRM Statistics Job, extension points 29","url":"https://jonas-paprotka.de/ref/codeunit/5350-crm-statistics-job/points/","author":"JOP-AL","license":"Metadata from Microsoft's symbol packages. AL source MIT, Copyright (c) Microsoft Corporation. Selection and wording © 2026 JOP-AL. https://jonas-paprotka.de/licenses/","subject":"Microsoft Dynamics 365 Business Central","checked":"2026-11-20","changed":"2026-10-05","object":{"type":"codeunit","id":5350,"name":"CRM Statistics Job","app":"Base Application","url":"https://jonas-paprotka.de/ref/codeunit/5350-crm-statistics-job/"},"major":29,"source":{"url":"https://jonas-paprotka.de/ref/codeunit/5350-crm-statistics-job/source/","path":"src/Layers/W1/BaseApp/Integration/D365Sales/CRMStatisticsJob.Codeunit.al","commit":"4303e5e584d3aa5d9e98cbc615525a5396ad6ed7","lines":"a line is <source url>#L<line>"},"steps":{"event":"[line, \"event\", name, handled]: raises an event of this object; handled 1 when it has an IsHandled parameter","call":"[line, \"call\", name, arguments]: calls a procedure of this object","ext":"[line, \"ext\", type, id, name, arguments]: calls a procedure of another object, through a variable declared with that type","write":"[line, \"write\", table id, method, 1 when called with true]: Insert, Modify, ModifyAll, Delete, DeleteAll or Rename","validate":"[line, \"validate\", table id, field name]","run":"[line, \"run\", type, id]: Codeunit.Run, Page.Run, Report.Run and their kin"},"objects":{"codeunit:5344":{"name":"CRM Product Name","url":"https://jonas-paprotka.de/ref/codeunit/5344-crm-product-name/"},"table:5330":{"name":"CRM Connection Setup","url":"https://jonas-paprotka.de/ref/table/5330-crm-connection-setup/"},"codeunit:5335":{"name":"Integration Table Synch.","url":"https://jonas-paprotka.de/ref/codeunit/5335-integration-table-synch/"},"table:5331":{"name":"CRM Integration Record","url":"https://jonas-paprotka.de/ref/table/5331-crm-integration-record/"},"table:5328":{"name":"CRM Synch Status","url":"https://jonas-paprotka.de/ref/table/5328-crm-synch-status/"},"codeunit:5330":{"name":"CRM Integration Management","url":"https://jonas-paprotka.de/ref/codeunit/5330-crm-integration-management/"},"table:18":{"name":"Customer","url":"https://jonas-paprotka.de/ref/table/18-customer/"},"codeunit:5342":{"name":"CRM Synch. Helper","url":"https://jonas-paprotka.de/ref/codeunit/5342-crm-synch-helper/"},"table:5367":{"name":"CRM Account Statistics","url":"https://jonas-paprotka.de/ref/table/5367-crm-account-statistics/"},"table:5341":{"name":"CRM Account","url":"https://jonas-paprotka.de/ref/table/5341-crm-account/"}},"procs":[{"name":"OnRun","line":19,"kind":"trigger","steps":[[21,"call","UpdateStatisticsAndInvoices",1]]},{"name":"UpdateStatisticsAndInvoices","line":41,"kind":"procedure","access":"local","params":1,"steps":[[48,"ext","codeunit",5344,"FULL",0],[51,"ext","table",5330,"RegisterConnectionWithName",1],[53,"ext","table",5330,"GetDefaultCRMConnection",1],[55,"call","UpdateAccountStatistics",1],[57,"call","UpdateInvoices",1],[59,"ext","table",5330,"UnregisterConnectionWithName",1]]},{"name":"UpdateAccountStatistics","line":62,"kind":"procedure","access":"local","params":1,"steps":[[77,"ext","codeunit",5335,"BeginIntegrationSynchJobLoging",4],[80,"call","InitializeCustomerStatisticsSynchronizationTime",0],[95,"call","UpdateCRMAccountStatisticsForCoupledCustomer",4],[98,"ext","codeunit",5335,"LogSynchError",3],[101,"write",5331,"Modify"],[104,"write",5331,"Modify"],[105,"ext","codeunit",5335,"IncrementSynchJobCounters",1],[116,"call","AddCustomersWithLedgerEntryActivity",2],[117,"call","AddCustomersWithLinesActivity",2],[125,"call","UpdateCRMAccountStatisticsForCoupledCustomer",4],[127,"ext","codeunit",5335,"LogSynchError",3],[130,"write",5331,"Modify"],[134,"write",5331,"Modify"],[136,"ext","codeunit",5335,"IncrementSynchJobCounters",1],[143,"write",5328,"Modify"],[149,"ext","codeunit",5335,"EndIntegrationSynchJobWithMsg",1],[149,"call","GetAccStatsUpdateFinalMessage",0]]},{"name":"InitializeCustomerStatisticsSynchronizationTime","line":152,"kind":"procedure","access":"local","params":0,"steps":[[157,"ext","codeunit",5330,"InitializeCRMSynchStatus",1],[161,"write",5328,"Modify"]]},{"name":"AddCustomersWithLinesActivity","line":181,"kind":"procedure","access":"local","params":2,"steps":[[195,"event","OnAfterAddCustomersWithLinesActivity",0]]},{"name":"UpdateInvoices","line":198,"kind":"procedure","access":"local","params":1,"steps":[[204,"ext","codeunit",5335,"BeginIntegrationSynchJobLoging",4],[207,"call","UpdateStatusOfPaidInvoices",0],[208,"ext","codeunit",5335,"UpdateSynchJobCounters",2],[210,"ext","codeunit",5335,"EndIntegrationSynchJobWithMsg",1],[210,"call","GetInvStatusUpdateFinalMessage",0]]},{"name":"UpdateCRMAccountStatisticsForCoupledCustomer","line":213,"kind":"procedure","access":"local","params":4,"steps":[[224,"ext","table",5331,"FindRecordId",1],[232,"call","CreateOrUpdateCRMAccountStatistics",2]]},{"name":"CreateOrUpdateCRMAccountStatistics","line":242,"kind":"procedure","params":2,"steps":[[250,"call","FindCRMAccountStatistics",2],[259,"ext","table",18,"GetTotalAmountLCY",0],[261,"ext","table",18,"CalcOverdueBalance",0],[263,"ext","table",18,"GetSalesLCY",0],[264,"ext","table",18,"GetInvoicedPrepmtAmountLCY",0],[265,"ext","codeunit",5342,"FindNAVLocalCurrencyInCRM",1],[266,"event","OnCreateOrUpdateCRMAccountStatisticsOnBeforeModify",0],[268,"write",5367,"Modify"],[271,"call","IsCRMAccountStatisticsModified",2],[272,"write",5367,"Modify"]]},{"name":"InitCRMAccountStatistics","line":308,"kind":"procedure","access":"local","params":1,"steps":[[325,"write",5367,"Insert"]]},{"name":"FindCRMAccountStatistics","line":328,"kind":"procedure","access":"local","params":2,"steps":[[331,"call","InitCRMAccountStatistics",1],[333,"call","ModifyCRMAccount",1]]},{"name":"ModifyCRMAccount","line":338,"kind":"procedure","access":"local","params":1,"steps":[[342,"ext","table",5331,"IsModifiedAfterLastSynchonizedCRMRecord",3],[343,"write",5341,"Modify"],[344,"ext","table",5331,"SetLastSynchCRMModifiedOn",3],[346,"write",5341,"Modify"]]},{"name":"UpdateStatusOfPaidInvoices","line":349,"kind":"procedure","params":1,"steps":[[358,"ext","codeunit",5330,"InitializeCRMSynchStatus",1],[369,"call","UpdateInvoice",2],[373,"call","UpdateInvoice",2],[376,"ext","table",5328,"UpdateLastUpdateInvoiceEntryNo",0]]},{"name":"UpdateInvoice","line":382,"kind":"procedure","access":"local","params":2,"steps":[[394,"ext","table",5331,"FindByRecordID",1],[395,"call","TryGetCRMInvoice",3],[397,"ext","codeunit",5342,"CancelCRMInvoice",1],[399,"ext","codeunit",5342,"UpdateCRMInvoiceStatusFromEntry",2]]},{"name":"TryGetCRMInvoice","line":402,"kind":"procedure","access":"local","params":3,"steps":[[407,"call","GetCRMInvoice",3]]},{"name":"DeleteAccountStatisticsOnAfterUncoupleRecord","line":438,"kind":"procedure","access":"local","params":3,"steps":[[450,"call","TryDeleteAccountStatistics",1]]},{"name":"TryDeleteAccountStatistics","line":455,"kind":"procedure","access":"local","params":1,"steps":[[461,"write",5367,"Delete"]]}]}