microsoft / ALAppExtensions

Repository for collaboration on Microsoft AL application add-on and localization extensions for Microsoft Dynamics 365 Business Central.
MIT License
778 stars 613 forks source link

[Event Request] OCR Service Mgt - OnAfterCorrectOCRFileNodes #27419

Open alinat2022 opened 10 hours ago

alinat2022 commented 10 hours ago

Describe the request

Hello.

We want to use the "OCR Data Correction" page to send to the OCR software new values of the fields filled in on this page, by using the "Send OCR Feedback" action. Currently, there is no event we could use in order to send also the values of our custom fields that we have added on the "OCR Data Correction" page.

Therefore, please create an event in procedure CorrectOCRFile from codeunit 1294 "OCR Service Mgt." and also remove the Scope = OnPrem from this procedure.

  // [Scope('OnPrem')] // <<Remove Scope = OnPrem>>
    procedure CorrectOCRFile(IncomingDocument: Record "Incoming Document"; var TempBlob: Codeunit "Temp Blob")
    var
        OCRFileXMLRootNode: DotNet XmlNode;
        OutStream: OutStream;
    begin
        ValidateUpdatedOCRFields(IncomingDocument);

        GetOriginalOCRXMLRootNode(IncomingDocument, OCRFileXMLRootNode);

        CorrectOCRFileNode(OCRFileXMLRootNode, IncomingDocument, IncomingDocument.FieldNo("Vendor Name"));
        CorrectOCRFileNode(OCRFileXMLRootNode, IncomingDocument, IncomingDocument.FieldNo("Vendor Invoice No."));
        CorrectOCRFileNode(OCRFileXMLRootNode, IncomingDocument, IncomingDocument.FieldNo("Order No."));
        CorrectOCRFileNode(OCRFileXMLRootNode, IncomingDocument, IncomingDocument.FieldNo("Document Date"));
        CorrectOCRFileNode(OCRFileXMLRootNode, IncomingDocument, IncomingDocument.FieldNo("Due Date"));
        CorrectOCRFileNode(OCRFileXMLRootNode, IncomingDocument, IncomingDocument.FieldNo("Amount Excl. VAT"));
        CorrectOCRFileNode(OCRFileXMLRootNode, IncomingDocument, IncomingDocument.FieldNo("Amount Incl. VAT"));
        CorrectOCRFileNode(OCRFileXMLRootNode, IncomingDocument, IncomingDocument.FieldNo("VAT Amount"));
        CorrectOCRFileNode(OCRFileXMLRootNode, IncomingDocument, IncomingDocument.FieldNo("Currency Code"));
        CorrectOCRFileNode(OCRFileXMLRootNode, IncomingDocument, IncomingDocument.FieldNo("Vendor VAT Registration No."));
        CorrectOCRFileNode(OCRFileXMLRootNode, IncomingDocument, IncomingDocument.FieldNo("Vendor IBAN"));
        CorrectOCRFileNode(OCRFileXMLRootNode, IncomingDocument, IncomingDocument.FieldNo("Vendor Bank Branch No."));
        CorrectOCRFileNode(OCRFileXMLRootNode, IncomingDocument, IncomingDocument.FieldNo("Vendor Bank Account No."));
        CorrectOCRFileNode(OCRFileXMLRootNode, IncomingDocument, IncomingDocument.FieldNo("Vendor Phone No."));
        OnAfterCorrectOCRFileNodes(OCRFileXMLRootNode, IncomingDocument,FieldNo); // <<New Event>>
        Clear(TempBlob);
        TempBlob.CreateOutStream(OutStream);
        OCRFileXMLRootNode.OwnerDocument.Save(OutStream);
    end;

    // <<New Event
    [IntegrationEvent(false, false)]
    local procedure OnAfterCorrectOCRFileNodes(var OCRFileXMLRootNode: DotNet XmlNode; var IncomingDocument: Record "Incoming Document"; FieldNo: Integer)
    begin
    end;
    // >>New Event

Additional context

We want to use the "OCR Data Correction" page to send to the OCR software new values of the fields filled in on this page, by using the "Send OCR Feedback" action. Currently, there is no event we could use in order to send also the values of our custom fields that we have added on the "OCR Data Correction" page.

Thank you. Internal work item: AB#555038

alinat2022 commented 4 hours ago

Hello, @Jose-agg . I also added something extra: to remove the Scope = OnPrem from the procedure. Can you please add this to your internal work item? Thank you in advance.