Wednesday, 19 July 2017

Dynamics NAV 2016 Applying and posting entries in code



Hello, i was doing some customization then i realized i had to post an application of a payment against an invoice in code. I felt the urge to share with someone there that may be facing a hurdle doing so. Just follow these easy steps.

  • Search and found the invoice record in the customer Ledger Entry table
  • Once you have find the invoice entry from the customer ledger entry table, Search for the payment entry as well from the customer ledger entry table
  • Edit and update the Invoice ledger Entry you found above
  • Set Applies to ID
  • Post Application
Here is a  sample code to achieve that;


  CustomerLdgEntryInv.RESET;//CustomerLdgEntryInv is a record variable of table 21
  CustomerLdgEntryInv.SETRANGE(CustomerLdgEntryInv."Document Type",      CustomerLdgEntryInv."Document Type"::Invoice);//Find only Invoices
 CustomerLdgEntryInv.SETRANGE(CustomerLdgEntryInv.Open, TRUE);// Find only Open entries    to apply
  IF CustomerLdgEntryInv.FINDFIRST THEN BEGIN
    // Search for Payment entries in customer ledger entries
      CustomerLdgEntry.RESET;//CustomerLdgEntryInv is a record variable of table 21
      CustomerLdgEntry.SETRANGE(CustomerLdgEntry."Document Type",    CustomerLdgEntry."Document Type"::Payment);// Find the payment
      CustomerLdgEntry.SETRANGE(CustomerLdgEntry.Open, TRUE);// Find the payment Ledger Entry
      IF CustomerLdgEntry.FINDFIRST THEN REPEAT//Repeat for all the payment entries
          //set applies to ID
          CustomerLdgEntry.CALCFIELDS(Amount);
      //Update all the invoice entries
          CustomerLdgEntryInv.CALCFIELDS(Amount);
          CustomerLdgEntryInv."Applying Entry" := TRUE;
          CustomerLdgEntryInv."Applies-to ID" := USERID;
          CustomerLdgEntryInv.CALCFIELDS("Remaining Amount");
          CustomerLdgEntryInv.VALIDATE("Amount to Apply", CustomerLdgEntryInv."Remaining Amount");
          CODEUNIT.RUN(CODEUNIT::"Cust. Entry-Edit", CustomerLdgEntryInv);
          COMMIT;// Commit the change
          SetAppliesToID.SetApplId(CustomerLdgEntry,CustomerLdgEntryInv,USERID);// SatAppliesToID is a codeUnit variable of Code Unit 101
          // Post the application
          PostAppn.Apply(CustomerLdgEntryInv,SalesInvoiceHeader."No.",SalesInvoiceHeader."Posting Date"); // PostAppn is a codeUnit variable of CodeUnit 226
      UNTIL CustomerLdgEntry.NEXT = 0;
  END;

I would like to hear your opinion of this blog and article. Please leave a comment
Best regards
      Author

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

Monday, 3 July 2017

Dynamics NAV Account Schedules


Hello, you may need a special report from your chart of accounts data but can't get one from the generic reports provided along with Dynamics NAV. The best alternative is not coding your own report but instead creating an account schedule. Account schedules in Dynamics NAV give you the power to define your own reports from Chart of Accounts data without writing any code. In fact you will not need technical knowledge to create one.
Click this for a step by step procedure . Click here for a you tube video about the same

Thursday, 29 June 2017

Cash Flow forecast in Dynamics NAV

Microsoft Dynamics NAV gives you the advantage to know your institution's financial solvency even at some future time. Such intelligence will give you the power to make informed decisions to keep your business moving on the right track. To learn more on cash flow features of Dynamics NAV please click here

Wednesday, 28 June 2017

Displaying report columns only when a user chooses to view them


Hello, are you trying to create a report where a user can choose to view certain columns but things ain't working as you expect? Don't worry you are safe. Here is what you need to do.

  • First create a global variable of type boolean to control when the column will appear on the report
  • Add the variable to the report request page. This enables the user to check and uncheck thus choosing whether to display column or not.
  • Add the variable to the report dataset so it is accessible in report layout in Visual Studio or Report Builder.
  • Select a column whose visibility you want to change based on user selection. Right click the column and select "Column Visibility". 
  • Change visibility based on an expression. for example =iif((Fields!ShowBilltoNo.Value=True),False,True). That expression will only display "Bill to No" column on the report when the user ticks the "showBilltoNo" field on the report request page. It's that simple, now do it and punch the air when stuff works. Good day


Tuesday, 30 May 2017

Dynamics NAV 2009 Classic client error "The extended stored procedure xp_ndo_enumusersids in the library file xp_ndo.dll, is not available on the server"



Do you get this error every time you try logging in via windows authentication on Dynamics NAV classic client? The reason is xp_ndo.dll is required for a successful login.
However you should not be affected by the error using database authentication.
If you need to use windows authentication, you will have to add the above library. click here for a walk through on how to add the library


Was this blog useful ? Please leave a comment

Dynamics NAV classic client Login error "The trace flag 4616 is not set on the server (local)"



Hello, you might facing the above error trying to login to Dynamics NAV classic client 2009.
That error pops up when logging in.
To stop the error you are required to set the trace flag in sql.
If you don't know how to set the trace flag click here for a walk through
Good day.

Was this blog useful? please leave a comment