{"title":"Codeunit 6177 E-Doc. Historical Matching, extension points 29","url":"https://jonas-paprotka.de/ref/codeunit/6177-e-doc-historical-matching/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":6177,"name":"E-Doc. Historical Matching","app":"E-Document Core","url":"https://jonas-paprotka.de/ref/codeunit/6177-e-doc-historical-matching/"},"major":29,"source":{"url":"https://jonas-paprotka.de/ref/codeunit/6177-e-doc-historical-matching/source/","path":"src/Apps/W1/EDocument/App/src/Processing/AI/Tools/EDocHistoricalMatching.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:8347":{"name":"Feature Configuration","url":"https://jonas-paprotka.de/ref/codeunit/8347-feature-configuration/"},"codeunit:6195":{"name":"E-Doc. AI Tool Processor","url":"https://jonas-paprotka.de/ref/codeunit/6195-e-doc-ai-tool-processor/"},"codeunit:7770":{"name":"AOAI Operation Response","url":"https://jonas-paprotka.de/ref/codeunit/7770-aoai-operation-response/"},"codeunit:7758":{"name":"AOAI Function Response","url":"https://jonas-paprotka.de/ref/codeunit/7758-aoai-function-response/"},"codeunit:6120":{"name":"E-Doc. Purchase Hist. Mapping","url":"https://jonas-paprotka.de/ref/codeunit/6120-e-doc-purchase-hist-mapping/"},"codeunit:6122":{"name":"E-Doc. Imp. Session Telemetry","url":"https://jonas-paprotka.de/ref/codeunit/6122-e-doc-imp-session-telemetry/"},"codeunit:8703":{"name":"Feature Telemetry","url":"https://jonas-paprotka.de/ref/codeunit/8703-feature-telemetry/"},"table:6101":{"name":"E-Document Purchase Line","url":"https://jonas-paprotka.de/ref/table/6101-e-document-purchase-line/"},"codeunit:8711":{"name":"Telemetry","url":"https://jonas-paprotka.de/ref/codeunit/8711-telemetry/"},"table:123":{"name":"Purch. Inv. Line","url":"https://jonas-paprotka.de/ref/table/123-purch-inv-line/"},"codeunit:6105":{"name":"E-Doc. Similar Descriptions","url":"https://jonas-paprotka.de/ref/codeunit/6105-e-doc-similar-descriptions/"},"table:6129":{"name":"EDoc Historical Match Buffer","url":"https://jonas-paprotka.de/ref/table/6129-edoc-historical-match-buffer/"},"codeunit:2200":{"name":"Azure Key Vault","url":"https://jonas-paprotka.de/ref/codeunit/2200-azure-key-vault/"}},"procs":[{"name":"OnRun","line":37,"kind":"trigger","steps":[[54,"call","DirectHistoricalMatch",1],[58,"ext","codeunit",8347,"GetConfiguration",1],[60,"call","PrepareHistoricalData",2],[63,"ext","codeunit",6195,"Setup",1],[65,"ext","codeunit",6195,"Process",2],[65,"call","CreateUserMessage",2],[68,"ext","codeunit",7770,"GetFunctionResponses",0],[69,"ext","codeunit",7758,"GetResult",0],[70,"event","OnGetHistoricalMatchFunctionResponse",0],[77,"call","TryValidateHistoricalMatchingRecord",1],[82,"ext","codeunit",6120,"UpdateMissingLineValuesFromHistory",4],[82,"call","GetConfidenceScore",1],[85,"ext","codeunit",6122,"SetLineBool",3],[90,"ext","codeunit",7770,"GetFunctionResponses",0],[93,"ext","codeunit",8703,"LogUsage",4],[93,"ext","codeunit",6195,"GetEDocumentMatchingAssistanceName",0],[93,"call","GetFeatureName",0]]},{"name":"DirectHistoricalMatch","line":96,"kind":"procedure","access":"local","params":1,"steps":[[120,"ext","codeunit",6120,"FindRelatedPurchaseLineInHistory",3],[122,"ext","codeunit",6120,"UpdateMissingLineValuesFromHistory",4],[124,"write",6101,"Modify",1],[125,"ext","codeunit",6122,"SetLineBool",3]]},{"name":"PrepareHistoricalData","line":168,"kind":"procedure","access":"local","params":2,"steps":[[188,"ext","codeunit",8711,"LogMessage",4],[196,"ext","codeunit",8711,"LogMessage",4],[201,"call","LoadHistoricalDataIntoTempTable",3],[203,"ext","codeunit",8703,"LogError",5],[203,"call","GetFeatureName",0],[207,"ext","codeunit",8711,"LogMessage",4],[213,"call","CollectPotentialMatches",3]]},{"name":"LoadHistoricalDataIntoTempTable","line":219,"kind":"procedure","access":"local","params":3,"steps":[[252,"write",123,"Insert"],[265,"write",123,"Modify"],[278,"ext","codeunit",8703,"LogUsage",4],[278,"call","GetFeatureName",0]]},{"name":"CollectPotentialMatches","line":281,"kind":"procedure","access":"local","params":3,"steps":[[287,"call","SearchAndAddMatches",6],[291,"call","SearchAndAddMatches",6],[295,"call","ProcessSimilarDescriptionsWithAI",3]]},{"name":"ProcessSimilarDescriptionsWithAI","line":299,"kind":"procedure","access":"local","params":3,"steps":[[304,"ext","codeunit",8711,"LogMessage",4],[306,"ext","codeunit",6105,"GetSimilarDescriptions",1],[312,"call","SearchAndAddMatches",6]]},{"name":"SearchAndAddMatches","line":316,"kind":"procedure","access":"local","params":6,"steps":[[324,"ext","codeunit",8711,"LogMessage",4],[343,"ext","codeunit",8711,"LogMessage",4],[346,"call","IsSimilarHistoricalRecordTracked",2],[357,"call","AddHistoricalMatchFromPurchInvLine",5],[361,"ext","codeunit",8711,"LogMessage",4]]},{"name":"IsSimilarHistoricalRecordTracked","line":364,"kind":"procedure","access":"local","params":2,"steps":[[376,"call","GetQuantityGroup",1],[382,"call","IsSimilarVariant",13]]},{"name":"AddHistoricalMatchFromPurchInvLine","line":396,"kind":"procedure","access":"local","params":5,"steps":[[416,"write",6129,"Insert"]]},{"name":"IsSimilarVariant","line":432,"kind":"procedure","access":"local","params":13,"steps":[[444,"call","GetQuantityGroup",1],[445,"call","GetQuantityGroup",1]]},{"name":"CreateUserMessage","line":476,"kind":"procedure","access":"local","params":2,"steps":[[488,"call","BuildEDocumentPurchaseLinesJson",1],[489,"call","BuildHistoricalMatchesJson",0],[502,"event","OnUserMessageCreated",0]]},{"name":"GetPrompt","line":580,"kind":"procedure","params":0,"steps":[[589,"call","GetName",0]]},{"name":"GetSystemPrompt","line":640,"kind":"procedure","params":1,"steps":[[649,"ext","codeunit",2200,"GetAzureKeyVaultSecret",2],[652,"call","GetFeatureName",0]]}]}