Thursday, 13 July 2017

Dynamics NAV Copy Document using Code




Hello, I was working on a project and i needed to copy a posted sales Invoice into a credit memo and post.
You may be trying to do the same. Let me save you the hurstle. Here's what you need to do.
You need to create a sales credit memo using the INIT function.Remember the INIT function ignores
the primary key. So VALIDATE the primary key for your credit memo
VALIDATE Sell-to Customer No. for your Credit memo
Here is a sample
SalesCreditMemo.INIT;// Initialises the Credit memo(SalesCreditMemo is a Record of table 36)
SalesCreditMemo.VALIDATE(SalesCreditMemo."No.",CrdMemoNo);//CrdMemoNo is a variable holding the Document No for the Sales Credit Memo
SalesCreditMemo.VALIDATE(SalesCreditMemo."Document Type",SalesCreditMemo."Document Type"::"Credit Memo");
SalesCreditMemo.VALIDATE(SalesCreditMemo."Sell-to Customer No.",[Put here your Customer No]);
SalesCreditMemo.INSERT;
Copy the lines from the posted sales Invoice
Here is a sample
//copy the Sales Invoice to the credit memo you have just made.
CopySalesDoc.SetSalesHeader(SalesCreditMemo);//CopySalesDoc is a Variable of Report 292
//CopyDocMgt is a variable of CodeUnite 6620
CopyDocMgt.SetProperties(TRUE,FALSE,FALSE,FALSE,FALSE,SalesSetup."Exact Cost Reversing Mandatory",FALSE);// SalesSetup is a Variable of Record 311
CopyDocMgt.CopySalesDoc(DocumentType::"Posted Invoice", [Put here Posted Sales Invoice Document No.],SalesCreditMemo);
//Post the credit memo
CLEAR(SalesPost);// SalesPost is a variable of CodeUnit 80
SalesPost.RUN(SalesCreditMemo);// This will post your Sales credit memo


************************************************************************************************
I would like to hear your feedback about this article. Please leave a comment.
Thank you
          Author

2 comments:

  1. Microsoft Dynamics Nav/Business Central: Dynamics Nav Copy Document Using Code >>>>> Download Now

    >>>>> Download Full

    Microsoft Dynamics Nav/Business Central: Dynamics Nav Copy Document Using Code >>>>> Download LINK

    >>>>> Download Now

    Microsoft Dynamics Nav/Business Central: Dynamics Nav Copy Document Using Code >>>>> Download Full

    >>>>> Download LINK EU

    ReplyDelete
  2. I cannot download this file how can download it?

    ReplyDelete