{"title":"Codeunit 5340 CRM Integration Table Synch., extension points 29","url":"https://jonas-paprotka.de/ref/codeunit/5340-crm-integration-table-synch/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":5340,"name":"CRM Integration Table Synch.","app":"Base Application","url":"https://jonas-paprotka.de/ref/codeunit/5340-crm-integration-table-synch/"},"major":29,"source":{"url":"https://jonas-paprotka.de/ref/codeunit/5340-crm-integration-table-synch/source/","path":"src/Layers/W1/BaseApp/Integration/Dataverse/CRMIntegrationTableSynch.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:5330":{"name":"CRM Integration Management","url":"https://jonas-paprotka.de/ref/codeunit/5330-crm-integration-management/"},"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:5341":{"name":"CRM Int. Table. Subscriber","url":"https://jonas-paprotka.de/ref/codeunit/5341-crm-int-table-subscriber/"},"codeunit:5336":{"name":"Integration Record Synch.","url":"https://jonas-paprotka.de/ref/codeunit/5336-integration-record-synch/"},"codeunit:4100":{"name":"Temp Blob","url":"https://jonas-paprotka.de/ref/codeunit/4100-temp-blob/"},"table:5335":{"name":"Integration Table Mapping","url":"https://jonas-paprotka.de/ref/table/5335-integration-table-mapping/"},"codeunit:10":{"name":"Type Helper","url":"https://jonas-paprotka.de/ref/codeunit/10-type-helper/"},"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:5373":{"name":"CRM Full Synch. Review Line","url":"https://jonas-paprotka.de/ref/table/5373-crm-full-synch-review-line/"},"table:7203":{"name":"CRM Payment Terms","url":"https://jonas-paprotka.de/ref/table/7203-crm-payment-terms/"},"table:7204":{"name":"CRM Freight Terms","url":"https://jonas-paprotka.de/ref/table/7204-crm-freight-terms/"},"table:7205":{"name":"CRM Shipping Method","url":"https://jonas-paprotka.de/ref/table/7205-crm-shipping-method/"},"table:5334":{"name":"CRM Option Mapping","url":"https://jonas-paprotka.de/ref/table/5334-crm-option-mapping/"},"codeunit:5342":{"name":"CRM Synch. Helper","url":"https://jonas-paprotka.de/ref/codeunit/5342-crm-synch-helper/"}},"procs":[{"name":"OnRun","line":20,"kind":"trigger","steps":[[30,"event","OnBeforeRun",1],[34,"call","InitConnection",0],[35,"call","TestConnection",0],[38,"call","SynchOption",1],[42,"call","PerformScheduledSynchToIntegrationTable",1],[44,"call","PerformScheduledSynchFromIntegrationTable",1],[49,"call","LocalUpdateTableMappingModifiedOn",2],[54,"call","CloseConnection",1]]},{"name":"InitConnection","line":79,"kind":"procedure","access":"internal","params":0,"steps":[[85,"ext","codeunit",5330,"OnInitCDSConnection",2],[91,"ext","codeunit",5344,"FULL",0],[95,"ext","table",5330,"RegisterConnectionWithName",1],[96,"call","ClearCache",0]]},{"name":"GetIntegrationUserId","line":99,"kind":"procedure","access":"local","params":0,"steps":[[106,"ext","codeunit",5330,"OnGetCDSIntegrationUserId",2],[110,"ext","table",5330,"GetIntegrationUserID",0]]},{"name":"TestConnection","line":113,"kind":"procedure","access":"internal","params":0,"steps":[[119,"ext","codeunit",5330,"OnTestCDSConnection",1],[121,"ext","table",5330,"TryReadSystemUsers",0]]},{"name":"CloseConnection","line":125,"kind":"procedure","access":"internal","params":1,"steps":[[131,"call","ClearCache",0],[133,"ext","codeunit",5330,"OnCloseCDSConnection",2],[137,"ext","table",5330,"UnregisterConnectionWithName",1]]},{"name":"ClearCache","line":140,"kind":"procedure","access":"local","params":0,"steps":[[143,"ext","codeunit",5341,"ClearCache",0]]},{"name":"IsModifiedByFilterNeeded","line":147,"kind":"procedure","access":"local","params":1,"steps":[[152,"event","OnIsModifiedByFilterNeeded",1],[160,"call","HasUnidirectionalFieldMappingFromIntegrationTable",1]]},{"name":"FindModifiedCRMRecords","line":164,"kind":"procedure","access":"local","params":3,"steps":[[173,"call","IsModifiedByFilterNeeded",1],[174,"ext","codeunit",5336,"SplitIntegrationTableFilter",2],[177,"call","SetIntRecordRefFilter",4],[182,"call","TryCopyRecordReference",4]]},{"name":"TryCopyRecordReference","line":190,"kind":"procedure","access":"local","params":4,"steps":[[192,"call","CopyRecordReference",4]]},{"name":"CopyRecordReference","line":195,"kind":"procedure","access":"local","params":4,"steps":[[213,"call","IsFieldMapped",3],[215,"ext","codeunit",4100,"FromFieldRef",1],[216,"ext","codeunit",4100,"ToFieldRef",1]]},{"name":"SetIntRecordRefFilter","line":241,"kind":"procedure","access":"local","params":4,"steps":[[256,"call","GetModifyByFieldNo",1],[260,"call","GetIntegrationUserId",0]]},{"name":"FindFailedNotSkippedCRMRecords","line":264,"kind":"procedure","access":"local","params":4,"steps":[[273,"ext","table",5335,"GetIntegrationTableFilter",0],[289,"ext","codeunit",5336,"GetIdFilterList",2],[290,"call","CacheFilteredCRMRecords",3]]},{"name":"CacheFilteredCRMRecords","line":298,"kind":"procedure","access":"local","params":3,"steps":[[310,"call","CopyRecordReference",4]]},{"name":"CacheFilteredCRMTable","line":318,"kind":"procedure","access":"local","params":3,"steps":[[323,"call","FindFailedNotSkippedCRMRecords",4],[324,"call","FindModifiedCRMRecords",3]]},{"name":"GetSourceRecordRef","line":343,"kind":"procedure","access":"local","params":3,"steps":[[348,"call","GetSourceType",1],[358,"ext","table",5335,"FindFilteredRec",2],[365,"ext","table",5335,"GetRecordRef",2],[366,"ext","table",5335,"GetExtendedIntegrationTableCaption",0],[367,"ext","table",5335,"FindFilteredRec",2]]},{"name":"FindFailedNotSkippedLocalRecords","line":383,"kind":"procedure","access":"local","params":3,"steps":[[391,"ext","table",5335,"GetTableFilter",0]]},{"name":"FindFailedNotSkippedLocalRecords","line":421,"kind":"procedure","access":"local","params":3,"steps":[[430,"ext","table",5335,"GetTableFilter",0]]},{"name":"SynchOption","line":463,"kind":"procedure","params":1,"steps":[[467,"ext","codeunit",10,"GetField",3],[471,"call","SynchOptions",1]]},{"name":"SynchRecord","line":474,"kind":"procedure","params":4,"steps":[[480,"call","GetSourceRecordRef",3],[481,"ext","codeunit",5335,"BeginIntegrationSynchJob",3],[483,"ext","codeunit",5335,"Synchronize",4],[484,"ext","codeunit",5335,"EndIntegrationSynchJob",0]]},{"name":"SynchRecordsToIntegrationTable","line":489,"kind":"procedure","params":3,"steps":[[496,"event","OnBeforeSynchRecordsToIntegrationTable",1],[500,"ext","table",5335,"FindMappingForTable",1],[508,"ext","codeunit",5335,"BeginIntegrationSynchJob",3],[512,"ext","codeunit",5335,"Synchronize",4],[514,"ext","codeunit",5335,"EndIntegrationSynchJob",0]]},{"name":"SynchRecordsFromIntegrationTable","line":518,"kind":"procedure","params":4,"steps":[[525,"event","OnBeforeSynchRecordsFromIntegrationTable",1],[529,"ext","table",5335,"FindMapping",2],[537,"ext","codeunit",5335,"BeginIntegrationSynchJob",3],[541,"ext","codeunit",5335,"Synchronize",4],[543,"ext","codeunit",5335,"EndIntegrationSynchJob",0]]},{"name":"SynchNAVTableToCRM","line":547,"kind":"procedure","access":"local","params":2,"steps":[[560,"ext","codeunit",5336,"SplitLocalTableFilter",2],[561,"call","CreateCRMIntegrationRecordClone",2],[564,"call","FindFailedNotSkippedLocalRecords",3],[567,"call","SyncNAVRecordToCRM",5],[570,"ext","codeunit",5336,"FindModifiedLocalRecords",3],[574,"call","SyncNAVRecordToCRM",5],[577,"event","OnSynchNAVTableToCRMOnBeforeCheckLatestModifiedOn",0]]},{"name":"SyncNAVRecordToCRM","line":582,"kind":"procedure","params":5,"steps":[[592,"event","OnQueryPostFilterIgnoreRecord",0],[595,"ext","table",5331,"IsIntegrationIdCoupled",2],[598,"ext","codeunit",5335,"Synchronize",4],[601,"ext","codeunit",5335,"GetRowLastModifiedOn",2]]},{"name":"SynchCRMTableToNAV","line":606,"kind":"procedure","access":"local","params":3,"steps":[[618,"call","CreateCRMIntegrationRecordClone",2],[619,"call","CacheFilteredCRMTable",3],[624,"call","CopyRecordReference",4],[626,"event","OnQueryPostFilterIgnoreRecord",0],[628,"ext","table",5331,"IsCRMRecordRefCoupled",1],[629,"write",5331,"Delete"],[633,"ext","codeunit",5335,"Synchronize",4],[636,"ext","codeunit",5335,"GetRowLastModifiedOn",2]]},{"name":"PerformScheduledSynchToIntegrationTable","line":654,"kind":"procedure","access":"local","params":1,"steps":[[663,"ext","codeunit",5335,"BeginIntegrationSynchJob",3],[666,"ext","table",5373,"FullSynchStarted",3],[667,"call","SynchNAVTableToCRM",2],[668,"ext","codeunit",5335,"EndIntegrationSynchJob",0],[669,"ext","table",5373,"FullSynchFinished",2]]},{"name":"PerformScheduledSynchFromIntegrationTable","line":675,"kind":"procedure","access":"local","params":1,"steps":[[685,"ext","codeunit",5335,"BeginIntegrationSynchJob",3],[688,"ext","table",5373,"FullSynchStarted",3],[689,"call","SynchCRMTableToNAV",3],[690,"ext","codeunit",5335,"EndIntegrationSynchJob",0],[691,"ext","table",5373,"FullSynchFinished",2]]},{"name":"LocalUpdateTableMappingModifiedOn","line":697,"kind":"procedure","access":"local","params":2,"steps":[[702,"event","OnBeforeUpdateTableMappingModifiedOn",1],[706,"ext","table",5335,"UpdateTableMappingModifiedOn",1]]},{"name":"CreateCRMIntegrationRecordClone","line":709,"kind":"procedure","access":"internal","params":2,"steps":[[715,"write",5331,"DeleteAll"],[717,"ext","codeunit",5330,"RepairBrokenCouplings",0],[724,"write",5331,"Insert"]]},{"name":"SynchOptions","line":728,"kind":"procedure","access":"local","params":1,"steps":[[734,"ext","table",5335,"SetOriginalJobQueueEntryOnHold",2],[738,"call","PerformScheduledOptionSynchToIntegrationTable",1],[740,"call","PerformScheduledOptionSynchFromIntegrationTable",1],[741,"call","LocalUpdateTableMappingModifiedOn",2],[742,"ext","table",5335,"SetOriginalJobQueueEntryStatus",2]]},{"name":"PerformScheduledOptionSynchFromIntegrationTable","line":745,"kind":"procedure","access":"local","params":1,"steps":[[754,"ext","codeunit",5335,"BeginIntegrationSynchJob",3],[757,"ext","table",5373,"FullSynchStarted",3],[758,"call","SynchCRMOptionToNAV",2],[759,"ext","codeunit",5335,"EndIntegrationSynchJob",0],[760,"ext","table",5373,"FullSynchFinished",2]]},{"name":"PerformScheduledOptionSynchToIntegrationTable","line":766,"kind":"procedure","access":"local","params":1,"steps":[[775,"ext","codeunit",5335,"BeginIntegrationSynchJob",3],[778,"ext","table",5373,"FullSynchStarted",3],[779,"call","SynchCRMOptionFromNAV",2],[780,"ext","codeunit",5335,"EndIntegrationSynchJob",0],[781,"ext","table",5373,"FullSynchFinished",2]]},{"name":"CacheFilteredCRMOptions","line":787,"kind":"procedure","access":"local","params":2,"steps":[[798,"call","LoadCRMOption",2],[800,"ext","table",5335,"GetIntegrationTableFilter",0]]},{"name":"LoadCRMOption","line":820,"kind":"procedure","params":2,"steps":[[829,"ext","table",7203,"Load",0],[834,"ext","table",7204,"Load",0],[839,"ext","table",7205,"Load",0],[843,"event","OnLoadCRMOption",0]]},{"name":"SynchCRMOptionToNAV","line":846,"kind":"procedure","access":"local","params":2,"steps":[[855,"call","CacheFilteredCRMOptions",2],[860,"ext","table",5334,"IsCRMRecordRefMapped",2],[864,"ext","codeunit",5335,"SynchronizeOption",4]]},{"name":"SynchCRMOptionFromNAV","line":870,"kind":"procedure","access":"local","params":2,"steps":[[881,"ext","codeunit",5336,"SplitLocalTableFilter",2],[884,"call","FindFailedNotSkippedLocalRecords",3],[887,"call","SyncNAVOptionToCRM",4],[890,"ext","codeunit",5336,"FindModifiedLocalRecords",3],[894,"call","SyncNAVOptionToCRM",4]]},{"name":"SyncNAVOptionToCRM","line":900,"kind":"procedure","access":"local","params":4,"steps":[[915,"ext","codeunit",5335,"SynchronizeOption",4],[918,"ext","codeunit",5335,"GetRowLastModifiedOn",2]]},{"name":"GetMaxNumberOfConditions","line":924,"kind":"procedure","params":0,"steps":[[930,"event","OnGetMaxNumberOfConditions",0],[932,"ext","codeunit",5336,"GetMaxNumberOfConditions",0]]},{"name":"IgnoreCompanyContactOnQueryPostFilterIgnoreRecord","line":981,"kind":"procedure","access":"local","params":2,"steps":[[990,"ext","codeunit",5342,"IsContactTypeCheckIgnored",0]]},{"name":"OnBeforeModifyJobQueueEntry","line":999,"kind":"procedure","access":"local","params":3,"steps":[[1006,"ext","table",5373,"OnBeforeModifyJobQueueEntry",1]]}]}