{"title":"Codeunit 5343 CRM Sales Order to Sales Order, extension points 29","url":"https://jonas-paprotka.de/ref/codeunit/5343-crm-sales-order-to-sales-order/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":5343,"name":"CRM Sales Order to Sales Order","app":"Base Application","url":"https://jonas-paprotka.de/ref/codeunit/5343-crm-sales-order-to-sales-order/"},"major":29,"source":{"url":"https://jonas-paprotka.de/ref/codeunit/5343-crm-sales-order-to-sales-order/source/","path":"src/Layers/W1/BaseApp/Integration/D365Sales/CRMSalesOrdertoSalesOrder.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/"},"codeunit:56":{"name":"Sales - Calc Discount By Type","url":"https://jonas-paprotka.de/ref/codeunit/56-sales-calc-discount-by-type/"},"table:5334":{"name":"CRM Option Mapping","url":"https://jonas-paprotka.de/ref/table/5334-crm-option-mapping/"},"table:36":{"name":"Sales Header","url":"https://jonas-paprotka.de/ref/table/36-sales-header/"},"table:5331":{"name":"CRM Integration Record","url":"https://jonas-paprotka.de/ref/table/5331-crm-integration-record/"},"table:5330":{"name":"CRM Connection Setup","url":"https://jonas-paprotka.de/ref/table/5330-crm-connection-setup/"},"codeunit:7201":{"name":"CDS Integration Impl.","url":"https://jonas-paprotka.de/ref/codeunit/7201-cds-integration-impl/"},"table:5353":{"name":"CRM Salesorder","url":"https://jonas-paprotka.de/ref/table/5353-crm-salesorder/"},"codeunit:7205":{"name":"CDS Int. Table. Subscriber","url":"https://jonas-paprotka.de/ref/codeunit/7205-cds-int-table-subscriber/"},"codeunit:5330":{"name":"CRM Integration Management","url":"https://jonas-paprotka.de/ref/codeunit/5330-crm-integration-management/"},"codeunit:5342":{"name":"CRM Synch. Helper","url":"https://jonas-paprotka.de/ref/codeunit/5342-crm-synch-helper/"},"codeunit:5336":{"name":"Integration Record Synch.","url":"https://jonas-paprotka.de/ref/codeunit/5336-integration-record-synch/"},"codeunit:5063":{"name":"ArchiveManagement","url":"https://jonas-paprotka.de/ref/codeunit/5063-archivemanagement/"},"table:5392":{"name":"CRM Annotation Coupling","url":"https://jonas-paprotka.de/ref/table/5392-crm-annotation-coupling/"},"codeunit:447":{"name":"Record Link Management","url":"https://jonas-paprotka.de/ref/codeunit/447-record-link-management/"},"table:2000000068":{"name":"Record Link","url":"https://jonas-paprotka.de/ref/table/2000000068-record-link/"},"table:37":{"name":"Sales Line","url":"https://jonas-paprotka.de/ref/table/37-sales-line/"},"codeunit:5331":{"name":"CRM Coupling Management","url":"https://jonas-paprotka.de/ref/codeunit/5331-crm-coupling-management/"},"table:311":{"name":"Sales & Receivables Setup","url":"https://jonas-paprotka.de/ref/table/311-sales-receivables-setup/"}},"procs":[{"name":"OnRun","line":26,"kind":"trigger","steps":[[30,"call","CreateInNAV",2]]},{"name":"ApplySalesOrderDiscounts","line":84,"kind":"procedure","access":"local","params":2,"steps":[[93,"ext","codeunit",5344,"CDSServiceName",0],[98,"ext","codeunit",56,"ApplyInvDiscBasedOnAmt",2],[104,"call","HideSalesOrderDiscountsDialog",0],[105,"ext","codeunit",5344,"CDSServiceName",0],[108,"ext","codeunit",5344,"CDSServiceName",0]]},{"name":"HideSalesOrderDiscountsDialog","line":111,"kind":"procedure","access":"local","params":0,"steps":[[113,"event","OnHideSalesOrderDiscountsDialog",0]]},{"name":"CopyCRMOptionFields","line":116,"kind":"procedure","access":"local","params":2,"steps":[[121,"ext","table",5334,"FindRecordID",3],[124,"validate",36,"Shipping Agent Code"],[126,"ext","table",5334,"GetRecordKeyValue",0],[128,"ext","table",5334,"FindRecordID",3],[131,"validate",36,"Payment Terms Code"],[133,"ext","table",5334,"GetRecordKeyValue",0],[135,"ext","table",5334,"FindRecordID",3],[138,"validate",36,"Shipment Method Code"],[140,"ext","table",5334,"GetRecordKeyValue",0]]},{"name":"CopyBillToInformationIfNotEmpty","line":143,"kind":"procedure","access":"local","params":2,"steps":[[148,"event","OnBeforeCopyBillToInformationIfNotEmpty",1],[162,"validate",36,"Bill-to Address"],[163,"validate",36,"Bill-to Address 2"],[164,"validate",36,"Bill-to Post Code"],[165,"validate",36,"Bill-to City"],[167,"event","OnCopyBillToInformationIfNotEmptyOnBeforeValidateBillToCountryRegionCode",1],[169,"validate",36,"Bill-to Country/Region Code"],[171,"validate",36,"Bill-to County"]]},{"name":"CopyShipToInformationIfNotEmpty","line":174,"kind":"procedure","access":"local","params":2,"steps":[[188,"validate",36,"Ship-to Address"],[189,"validate",36,"Ship-to Address 2"],[190,"validate",36,"Ship-to Post Code"],[191,"validate",36,"Ship-to City"],[193,"event","OnCopyShipToInformationIfNotEmptyOnBeforeValidateShipToCountryRegionCode",1],[195,"validate",36,"Ship-to Country/Region Code"],[197,"validate",36,"Ship-to County"],[198,"event","OnAfterCopyShipToInformationIfNotEmpty",0]]},{"name":"SetLineDescription","line":201,"kind":"procedure","access":"local","params":3,"steps":[[210,"event","OnBeforeSetLineDescription",1],[237,"call","CreateExtendedDescriptionOrderLines",3],[242,"call","CreateExtendedDescriptionOrderLines",3]]},{"name":"CoupledSalesHeaderExists","line":246,"kind":"procedure","access":"local","params":2,"steps":[[252,"ext","table",5331,"FindRecordIDFromID",3]]},{"name":"CreateInNAV","line":268,"kind":"procedure","params":2,"steps":[[273,"ext","table",5330,"IsEnabled",0],[274,"ext","codeunit",5344,"SHORT",0],[279,"event","OnCreateInNAVOnBeforeCheckState",1],[282,"call","CreateNAVSalesOrder",2]]},{"name":"CreateNAVSalesOrder","line":285,"kind":"procedure","access":"local","params":2,"steps":[[295,"ext","table",5331,"FindByCRMID",1],[296,"call","CreateSalesOrderHeader",2],[297,"ext","table",5331,"CoupleRecordIdToCRMID",2],[298,"call","CreateSalesOrderNotes",2],[299,"call","CreateSalesOrderLines",2],[300,"call","ApplySalesOrderDiscounts",2],[302,"call","SetCompanyId",1],[303,"call","SetLastBackOfficeSubmit",2],[304,"event","OnCreateNAVSalesOrderOnAfterSetLastBackOfficeSubmit",0],[305,"ext","codeunit",5344,"CDSServiceName",0],[307,"call","CoupledSalesHeaderExists",2],[309,"ext","codeunit",5344,"CDSServiceName",0],[310,"ext","codeunit",5344,"CDSServiceName",0],[314,"call","ReferencedSalesInvoiceHeaderExists",2],[316,"ext","codeunit",5344,"CDSServiceName",0],[317,"ext","codeunit",5344,"CDSServiceName",0],[322,"event","OnAfterCreateNAVSalesOrder",0]]},{"name":"SetCompanyId","line":326,"kind":"procedure","access":"local","params":1,"steps":[[332,"ext","codeunit",7201,"IsIntegrationEnabled",0],[335,"write",5353,"Modify"],[336,"ext","codeunit",7205,"SetCompanyId",1],[339,"write",5353,"Modify"]]},{"name":"TryResetLastBackofficeSubmitOnCRMSalesOrder","line":344,"kind":"procedure","access":"local","params":1,"steps":[[350,"ext","codeunit",5344,"CDSServiceName",0],[355,"write",5353,"Modify"],[357,"write",5353,"Modify"],[359,"ext","codeunit",5344,"CDSServiceName",0],[361,"ext","codeunit",5344,"CDSServiceName",0]]},{"name":"RemoveCouplingToCRMSalesOrderOnSalesHeaderDelete","line":365,"kind":"procedure","access":"local","params":2,"steps":[[383,"ext","codeunit",5330,"IsCRMIntegrationEnabled",0],[386,"ext","table",5330,"IsBidirectionalSalesOrderIntEnabled",0],[389,"ext","table",5331,"FindIDFromRecordID",2],[392,"ext","codeunit",5344,"CDSServiceName",0],[394,"ext","codeunit",5330,"IsWorkingConnection",0],[395,"ext","codeunit",5344,"CDSServiceName",0],[399,"ext","codeunit",5330,"RemoveCoupling",2],[400,"ext","codeunit",5344,"CDSServiceName",0],[401,"call","TryResetLastBackofficeSubmitOnCRMSalesOrder",1],[402,"ext","codeunit",5344,"CDSServiceName",0],[404,"ext","codeunit",5344,"CDSServiceName",0]]},{"name":"OnBeforeSalesLineCheckAvailShowWarning","line":408,"kind":"procedure","access":"local","params":2,"steps":[[420,"ext","codeunit",5330,"IsCRMIntegrationEnabled",0],[426,"ext","table",5331,"IsRecordCoupled",1]]},{"name":"CreateSalesOrderHeader","line":432,"kind":"procedure","access":"local","params":2,"steps":[[445,"ext","codeunit",5344,"CDSServiceName",0],[447,"validate",36,"Document Type"],[448,"validate",36,"Status"],[449,"ext","table",36,"InitInsert",0],[450,"call","GetCoupledCustomer",2],[451,"validate",36,"Sell-to Customer No."],[452,"validate",36,"Sell-to Contact No."],[453,"validate",36,"Your Reference"],[454,"validate",36,"Currency Code"],[454,"ext","codeunit",5342,"GetNavCurrencyCode",1],[455,"validate",36,"Requested Delivery Date"],[456,"call","CopyBillToInformationIfNotEmpty",2],[457,"call","CopyShipToInformationIfNotEmpty",2],[458,"call","CopyCRMOptionFields",2],[459,"event","OnSetSalesHeaderPaymentDiscountFromCRM",1],[461,"validate",36,"Payment Discount %"],[462,"validate",36,"External Document No."],[467,"ext","codeunit",5336,"SetTextValue",2],[467,"ext","codeunit",5336,"GetTextValue",1],[476,"ext","codeunit",5063,"ArchSalesDocumentNoConfirm",1],[480,"event","OnCreateSalesOrderHeaderOnBeforeSalesHeaderInsert",0],[481,"write",36,"Insert"],[482,"ext","codeunit",5344,"CDSServiceName",0]]},{"name":"CreateSalesOrderNotes","line":485,"kind":"procedure","access":"local","params":2,"steps":[[491,"ext","codeunit",5344,"CDSServiceName",0],[497,"call","CreateNote",3],[498,"ext","table",5392,"CoupleRecordLinkToCRMAnnotation",2],[500,"ext","codeunit",5344,"CDSServiceName",0],[502,"ext","codeunit",5344,"CDSServiceName",0]]},{"name":"CreateNote","line":506,"kind":"procedure","params":3,"steps":[[520,"ext","table",5392,"ExtractNoteText",1],[521,"ext","codeunit",447,"WriteNote",2],[524,"write",2000000068,"Insert"]]},{"name":"CreateSalesOrderLines","line":527,"kind":"procedure","access":"local","params":2,"steps":[[532,"ext","codeunit",5344,"CDSServiceName",0],[541,"call","InitializeSalesOrderLine",3],[542,"event","OnCreateSalesOrderLinesOnBeforeSalesLineInsert",0],[543,"write",37,"Insert",1],[545,"validate",37,"Qty. to Assemble to Order"],[547,"ext","codeunit",5344,"CDSServiceName",0],[549,"validate",37,"Document Type"],[550,"validate",37,"Document No."],[551,"ext","codeunit",5344,"CDSServiceName",0],[554,"ext","table",37,"InsertFreightLine",1]]},{"name":"CreateExtendedDescriptionOrderLines","line":557,"kind":"procedure","params":3,"steps":[[562,"call","InitNewSalesLine",2],[564,"validate",37,"Description"],[566,"write",37,"Insert"]]},{"name":"CRMIsCoupledToValidRecord","line":572,"kind":"procedure","params":2,"steps":[[578,"ext","codeunit",5330,"IsCRMIntegrationEnabled",0],[579,"ext","codeunit",5331,"IsRecordCoupledToNAV",2],[580,"call","CoupledSalesHeaderExists",2]]},{"name":"GetCoupledCRMSalesorder","line":589,"kind":"procedure","params":2,"steps":[[596,"ext","codeunit",5344,"CDSServiceName",0],[598,"ext","table",5331,"FindIDFromRecordID",2],[599,"ext","codeunit",5344,"CDSServiceName",0],[605,"ext","codeunit",5330,"RemoveCoupling",4],[606,"ext","codeunit",5344,"CDSServiceName",0]]},{"name":"GetCoupledCustomer","line":609,"kind":"procedure","params":2,"steps":[[618,"event","OnBeforeGetCoupledCustomer",1],[623,"ext","codeunit",5344,"CDSServiceName",0],[626,"call","GetCRMAccountOfCRMSalesOrder",2],[627,"ext","codeunit",5344,"CDSServiceName",0],[630,"ext","table",5331,"FindRecordIDFromID",3],[631,"ext","codeunit",5344,"CDSServiceName",0]]},{"name":"GetCoupledSalesHeader","line":636,"kind":"procedure","params":2,"steps":[[643,"ext","codeunit",5344,"CDSServiceName",0],[646,"ext","table",5331,"FindRecordIDFromID",3],[647,"ext","codeunit",5344,"CDSServiceName",0],[653,"ext","codeunit",5330,"RemoveCoupling",4],[654,"ext","codeunit",5344,"CDSServiceName",0]]},{"name":"GetCRMAccountOfCRMSalesOrder","line":657,"kind":"procedure","params":2,"steps":[[663,"event","OnBeforeGetCRMAccountOfCRMSalesOrder",1],[670,"ext","codeunit",5344,"CDSServiceName",0],[671,"ext","codeunit",5344,"CDSServiceName",0]]},{"name":"InitNewSalesLine","line":689,"kind":"procedure","access":"local","params":2,"steps":[[692,"validate",37,"Document Type"],[693,"validate",37,"Document No."],[695,"validate",37,"Line No."]]},{"name":"InitializeSalesOrderLine","line":698,"kind":"procedure","access":"local","params":3,"steps":[[709,"call","InitNewSalesLine",2],[712,"event","OnInitializeSalesOrderLineOnBeforeInitializeWriteInOrderLine",1],[715,"call","InitializeWriteInOrderLine",1],[721,"call","InitializeSalesOrderLineFromItem",2],[723,"call","InitializeSalesOrderLineFromResource",2],[726,"event","OnInitializeSalesOrderLineOnBeforeUnexpectedProductTypeErr",1],[733,"call","SetLineDescription",3],[735,"ext","codeunit",5330,"IsUnitGroupMappingEnabled",0],[736,"call","UpdateSalesLineUnitOfMeasure",3],[738,"validate",37,"Quantity"],[742,"event","OnInitializeSalesOrderLineOnAfterCalcUpdateItemUnitPriceNeeded",0],[750,"validate",37,"Unit Price"],[752,"validate",37,"Line Discount Amount"]]},{"name":"UpdateSalesLineUnitOfMeasure","line":758,"kind":"procedure","access":"local","params":3,"steps":[[772,"ext","table",5331,"FindRecordIDFromID",3],[773,"ext","codeunit",5344,"CDSServiceName",0],[778,"validate",37,"Unit of Measure Code"],[782,"ext","table",5331,"FindRecordIDFromID",3],[783,"ext","codeunit",5344,"CDSServiceName",0],[788,"validate",37,"Unit of Measure Code"]]},{"name":"InitializeSalesOrderLineFromItem","line":793,"kind":"procedure","access":"local","params":2,"steps":[[800,"ext","table",5331,"FindRecordIDFromID",3],[801,"ext","codeunit",5344,"CDSServiceName",0],[805,"validate",37,"Type"],[806,"validate",37,"No."]]},{"name":"InitializeSalesOrderLineFromResource","line":809,"kind":"procedure","access":"local","params":2,"steps":[[816,"ext","table",5331,"FindRecordIDFromID",3],[817,"ext","codeunit",5344,"CDSServiceName",0],[821,"validate",37,"Type"],[822,"validate",37,"No."]]},{"name":"InitializeWriteInOrderLine","line":825,"kind":"procedure","access":"local","params":1,"steps":[[831,"ext","codeunit",5344,"CDSServiceName",0],[832,"ext","codeunit",5344,"CDSServiceName",0],[832,"ext","table",37,"GetSalesHeader",0],[834,"validate",311,"Write-in Product No."],[837,"validate",37,"Type"],[839,"validate",37,"Type"],[841,"validate",37,"No."]]},{"name":"SetLastBackOfficeSubmit","line":845,"kind":"procedure","params":2,"steps":[[848,"ext","codeunit",5344,"CDSServiceName",0],[850,"write",5353,"Modify",1],[852,"write",5353,"Modify",1],[854,"write",5353,"Modify",1],[855,"ext","codeunit",5344,"CDSServiceName",0]]}]}