ALAppExtensions icon indicating copy to clipboard operation
ALAppExtensions copied to clipboard

Incomming Doc

Open clausmacali opened this issue 7 years ago • 9 comments

This is regarding the error “Cannot create the document. Make sure the data exchange definition is correct” (EntityNotFoundErr) and this error is from the table “Incoming Document”. This error is because in the base code after processing the "Incoming Document" system checks if it can find the incoming document entry in any of the following tables filtered with the "Entry No." from the "Incoming Document". "Purchase Header" PurchaseHeader.SETRANGE("Incoming Document Entry No.","Entry No."); "Sales Header" SalesHeader.SETRANGE("Incoming Document Entry No.","Entry No."); "Gen. Journal Line" GenJournalLine.SETRANGE("Incoming Document Entry No.","Entry No."); If nothing is found we are left with that error. In our case based on the scenario the entries are created in the "Job Journal" and there is no code in base that checks this table or any event to extend the function UpdateDocumentFields. It would be great if Microsoft Publishes an event in which we can check other tables like "Job Journal" and then exit with error. Code Table - 130 - "Incoming Document" Code Execution Sequence [External] CreateDocumentWithDataExchange() LOCAL CreateWithDataExchange(DocumentType : Option) // identify the created doc IF NOT UpdateDocumentFields THEN BEGIN SetProcessFailed(''); EXIT; END; LOCAL [TryFunction] UpdateDocumentFields() // If purchase PurchaseHeader.SETRANGE("Incoming Document Entry No.","Entry No."); IF PurchaseHeader.FINDFIRST THEN BEGIN CASE PurchaseHeader."Document Type" OF PurchaseHeader."Document Type"::Invoice: "Document Type" := "Document Type"::"Purchase Invoice"; PurchaseHeader."Document Type"::"Credit Memo": "Document Type" := "Document Type"::"Purchase Credit Memo"; ELSE ERROR(NotSupportedPurchErr,FORMAT(PurchaseHeader."Document Type")); END; "Document No." := PurchaseHeader."No."; EXIT; END; // If sales SalesHeader.SETRANGE("Incoming Document Entry No.","Entry No."); IF SalesHeader.FINDFIRST THEN BEGIN CASE SalesHeader."Document Type" OF SalesHeader."Document Type"::Invoice: "Document Type" := "Document Type"::"Sales Invoice"; SalesHeader."Document Type"::"Credit Memo": "Document Type" := "Document Type"::"Sales Credit Memo"; ELSE ERROR(NotSupportedSalesErr,FORMAT(SalesHeader."Document Type")); END; "Document No." := SalesHeader."No."; EXIT; END; // If general journal line GenJournalLine.SETRANGE("Incoming Document Entry No.","Entry No."); IF GenJournalLine.FINDFIRST THEN BEGIN "Document No." := GenJournalLine."Document No."; EXIT; END; //ERROR(EntityNotFoundErr); //Call a Publisher Event here with Current Record and Boolean //Parameter – DocExists. //If the DocExists is False then throw the error. AfterUpdateDocumentFields(IncomingDocument: Record “Incoming Document”; VAR DocExists: Boolean); //IntegrationEvent IF NOT DocExists THEN ERROR(EntityNotFoundErr);

clausmacali avatar Jan 21 '19 19:01 clausmacali

A little formatting would really help us understand your issue faster and better :-)

JesperSchulz avatar Jan 23 '19 09:01 JesperSchulz

This is already solved, we have this in the end of UpdateDocumentFields procedure:

DocExists := FALSE; OnAfterUpdateDocumentFields(Rec,DocExists); IF NOT DocExists THEN ERROR(EntityNotFoundErr);

AlexanderYakunin avatar Jan 23 '19 13:01 AlexanderYakunin

Hi Alexander

Thanks 😊

Med venlig hilsen Best Regards

Claus Petersen MACALI ApS Hegnsgårdsvej 38 DK-7120 Vejle Ø [email protected]

Mobil + 45 52 23 70 70


[macali-03] [navapp-05]


Fra: Alexander Yakunin [email protected] Sendt: 23. januar 2019 14:51 Til: Microsoft/ALAppExtensions [email protected] Cc: Claus Petersen [email protected]; Author [email protected] Emne: Re: [Microsoft/ALAppExtensions] Incomming Doc (#905)

This is already solved, we have this in the end of UpdateDocumentFields procedure:

DocExists := FALSE; OnAfterUpdateDocumentFields(Rec,DocExists); IF NOT DocExists THEN ERROR(EntityNotFoundErr);

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/Microsoft/ALAppExtensions/issues/905#issuecomment-456808092, or mute the threadhttps://github.com/notifications/unsubscribe-auth/Ajd18dtIyOlTJsVCEP9FkS2LCyEmWAC-ks5vGGjCgaJpZM4aLY5M.

clausmacali avatar Jan 23 '19 13:01 clausmacali

Just tested this but we need this VAR

OnAfterUpdateDocumentFields(VAR IncomingDocument: Record “Incoming Document”; VAR DocExists: Boolean);

clausmacali avatar Jan 23 '19 14:01 clausmacali

OnAfterUpdateDocumentFields(VAR IncomingDocument: Record “Incoming Document”; VAR DocExists: Boolean);

Med venlig hilsen Best Regards

Claus Petersen MACALI ApS Hegnsgårdsvej 38 DK-7120 Vejle Ø [email protected]

Mobil + 45 52 23 70 70


[macali-03] [navapp-05]


Fra: Jesper Schulz-Wedde [email protected] Sendt: 23. januar 2019 10:55 Til: Microsoft/ALAppExtensions [email protected] Cc: Claus Petersen [email protected]; Author [email protected] Emne: Re: [Microsoft/ALAppExtensions] Incomming Doc (#905)

A little formatting would really help us understand your issue faster and better :-)

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/Microsoft/ALAppExtensions/issues/905#issuecomment-456739245, or mute the threadhttps://github.com/notifications/unsubscribe-auth/Ajd18bxDCUOC-6TgyU6N4ZSMeW_G0YQYks5vGDGCgaJpZM4aLY5M.

clausmacali avatar Jan 23 '19 14:01 clausmacali

We have it:

LOCAL [IntegrationEvent] OnAfterUpdateDocumentFields(VAR IncomingDocument : Record "Incoming Document";VAR DocExists : Boolean)

AlexanderYakunin avatar Jan 23 '19 14:01 AlexanderYakunin

Thanks, and then we also have this

Can you Add that VAR to that Function. ​ Otherwise the DocExists will not get updated. ​ So to update the DocExits and the IncomingDocument we need the VAR Parameter.

AL Code : [EventSubscriber(ObjectType::Table, Database::"Incoming Document", 'OnAfterUpdateDocumentFields', '', true, true)] localprocedure AfterUpdateDocumentFields(var IncomingDocument: Record "Incoming Document"; var DocExists: Boolean) var lJobJournalLine: Record "Job Journal Line"; begin lJobJournalLine.Reset(); lJobJournalLine.SetRange("Macali AT Incoming Doc. Entry No.", IncomingDocument."Entry No."); if lJobJournalLine.FindFirst() thenbegin IncomingDocument."Document Type" := IncomingDocument."Document Type"::Journal; IncomingDocument."Document No." := lJobJournalLine."Document No."; DocExists := true; end; end;

Med venlig hilsen Best Regards

Claus Petersen MACALI ApS Hegnsgårdsvej 38 DK-7120 Vejle Ø [email protected]

Mobil + 45 52 23 70 70


[macali-03] [navapp-05]


Fra: Alexander Yakunin [email protected] Sendt: 23. januar 2019 15:50 Til: Microsoft/ALAppExtensions [email protected] Cc: Claus Petersen [email protected]; Author [email protected] Emne: Re: [Microsoft/ALAppExtensions] Incomming Doc (#905)

We have it:

LOCAL [IntegrationEvent] OnAfterUpdateDocumentFields(VAR IncomingDocument : Record "Incoming Document";VAR DocExists : Boolean)

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/Microsoft/ALAppExtensions/issues/905#issuecomment-456829395, or mute the threadhttps://github.com/notifications/unsubscribe-auth/Ajd18cTb9Nq4J_jqjkN8alwg268WWk90ks5vGHargaJpZM4aLY5M.

clausmacali avatar Jan 23 '19 15:01 clausmacali

And And these other events ? VAR is wanted

OnAfterFindPostedRecord(VAR IncomingDocument : Record "Incoming Document";VAR RelatedRecord : Variant;VAR RecordFound : Boolean)

OnAfterFindUnpostedRecord(VAR IncomingDocument : Record "Incoming Document";VAR RelatedRecord : Variant;VAR RecordFound : Boolean) ​

Those are in the same Table - 130

Med venlig hilsen Best Regards

Claus Petersen MACALI ApS Hegnsgårdsvej 38 DK-7120 Vejle Ø [email protected]

Mobil + 45 52 23 70 70


[macali-03] [navapp-05]


Fra: Alexander Yakunin [email protected] Sendt: 23. januar 2019 15:50 Til: Microsoft/ALAppExtensions [email protected] Cc: Claus Petersen [email protected]; Author [email protected] Emne: Re: [Microsoft/ALAppExtensions] Incomming Doc (#905)

We have it:

LOCAL [IntegrationEvent] OnAfterUpdateDocumentFields(VAR IncomingDocument : Record "Incoming Document";VAR DocExists : Boolean)

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/Microsoft/ALAppExtensions/issues/905#issuecomment-456829395, or mute the threadhttps://github.com/notifications/unsubscribe-auth/Ajd18cTb9Nq4J_jqjkN8alwg268WWk90ks5vGHargaJpZM4aLY5M.

clausmacali avatar Jan 23 '19 15:01 clausmacali

Any updates, or shall I make a new case

clausmacali avatar Jan 30 '19 20:01 clausmacali