Skip to main content

Notifications

Announcements

No record found.

Small and medium business | Business Central, N...
Suggested answer

Troubleshooting Document Processing in D365: Error with Interface Implementation

Posted on by 80

Hi Everyone,

I am currently implementing a new feature in Business Central using interfaces, but I have encountered a problem. I would appreciate any insights or assistance regarding this issue. Thank you!

 
interface "IDocumentProcessor"
{
    procedure ProcessDocument();
}
interface "IExtendedDocumentProcessor" extends IDocumentProcessor
{
    procedure ValidateDocument();
}
codeunit 50100 SalesInvoiceProcessor implements IExtendedDocumentProcessor
{
    procedure ProcessDocument()
    var
        MessageText: Text;
    begin
        MessageText := 'Processing Sales Invoice...';
        Message(MessageText);
    end;
    procedure ValidateDocument()
    begin
        Message('Validating Sales Invoice...');
    end;
}
codeunit 50101 SalesOrderProcessor implements IExtendedDocumentProcessor
{
    procedure ProcessDocument()
    begin
        Message('Processing Sales Order...');
    end;
    procedure ValidateDocument()
    begin
        Message('Validating Sales Order...');
    end;
}
enum 50100 DocumentType implements IExtendedDocumentProcessor
{
    Extensible = true;
    value(0; SalesInvoice)
    {
        Caption = 'Sales Invoice';
        Implementation =  IExtendedDocumentProcessor = SalesInvoiceProcessor;
    }
    value(1; SalesOrder)
    {
        Caption = 'Sales Order';
        Implementation =  IExtendedDocumentProcessor = SalesOrderProcessor;
    }
}
page 50100 DocumentProcessingPage
{
    PageType = Card;
    ApplicationArea = All;
    UsageCategory = Administration;
    Caption = 'Document Processing';
    layout
    {
        area(Content)
        {
            group(Group)
            {
                field(DocumentTypeField; DocumentType)
                {
                    Caption = 'Select Document Type';
                }
            }
        }
    }
    actions
    {
        area(Processing)
        {
            action(ProcessDocument)
            {
                Caption = 'Process Document';
                trigger OnAction()
                var
                    DocumentProcessor: Interface IExtendedDocumentProcessor;
                begin
                    DocumentProcessorFactory(DocumentProcessor);
                    DocumentProcessor.ProcessDocument();   //I'm getting error at this point, If im commenting this im getting output for ValidateDocument.
                    DocumentProcessor.ValidateDocument();
                end;
            }
        }
    }
    local procedure DocumentProcessorFactory(var iDocumentProcessor: Interface IExtendedDocumentProcessor)
    begin
        iDocumentProcessor := DocumentType;
    end;
    var
        DocumentType: enum DocumentType;
}
 
ERROR
 
If requesting support, please provide the following details to help troubleshooting:
Error message: 
Function ID -1045640884 was called. The object with ID 0 does not have a member with that ID.
Internal session ID: 
ae98ddd9-65ac-44ad-ada7-abe7d3618389
Application Insights session ID: 
22fb8d08-be5e-4d91-ae28-c7d982cd7e09
Client activity id: 
7c1505a4-7b10-4b22-86f0-f471580eaf57
Time stamp on error: 
2024-10-18T04:10:21.2018751Z
User telemetry id: 
a47a7ce1-1747-442f-841b-cd2ecfcc0893
AL call stack: 
DocumentProcessingPage(Page 50100)."ProcessDocument - OnAction"(Trigger) line 5 - 17Oct by Default Publisher

 
Categories:
  • Suggested answer
    Khushbu Rajvi. Profile Picture
    Khushbu Rajvi. 4,615 on at
    Troubleshooting Document Processing in D365: Error with Interface Implementation
    The error message you're seeing indicates that the system is trying to call a function with an ID that doesn't exist in the current context. This usually happens when there are issues with how the interfaces and implementations are referenced or instantiated.
  • gdrenteria Profile Picture
    gdrenteria 12,183 Most Valuable Professional on at
    Troubleshooting Document Processing in D365: Error with Interface Implementation
    Hi
    Can you try completely uninstalling and reinstalling?
    Best
    GR

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans