Monday 22 October 2018

Better way to view, print, email and archive SSRS reports in D365FO

Recently I have got a requirement from a client in which they wanted to email invoices in Dynamics 365 for Finance and Operations, with the nicely shaped email body containing meaningful information such as Invoice ID and Customer reference. They also wanted to attach additional documents such as invoice specifications to these emails.

When I start searching on the Internet looking for a solution, I have discovered a pretty good tool that runs side by side with built-in SSRS reports and provides far better options regarding report print destinations including Email. The best part is that this tool is entirely free of charge.

I will describe in my next article how I used it to implement my scenario for emailing invoices, but right now I want to share with you guys what else I have learned about this tool and give you a quick overview.

The tool is called Docentric and consists only of models so it’s really lightweight. It doesn’t use over-layering so you are on the safe side here. Installation process means importing models and synchronizing the database so it takes hardly 15-20 minutes.

When you install it, start any report and open the Print destination settings form. You will notice a new link Show Docentric destinations as shown on the image below. When you click it, Docentric print destinations will open, bringing many new possibilities to the table.
























Let’s make a quick tour.

Docentric Email Print Destination:

The first thing that made me very happy is a possibility to create an HTML email body with dynamic parts. Depending on a report you will be able to use some contextual information in the email body, for example Invoice ID or Customer account number. Besides plain text placeholders, there are also image placeholders you can use such as Company logo or Worker image. You can pick among them in the Fields drop-down list in the email body editor.
























You can also switch to the full screen mode to better design your email body as I did for my scenario, but I will explain more in the next article.



















This is not all – you can use the same placeholders (@InvoiceId@, @InvoiceAccount@, etc.) also to form the email subject or attachment name. Moreover, you can use all of them in all other print destinations, for example in output filename when printing the report to File.
























Docentric Screen Print Destination:

I personally liked very much Docentric report viewer because pagination and zooming work as expected. In addition, you can print to local printers directly from Docentric viewer while from SSRS viewer you can print only to Network printers registered in D365FO.

But there is one more thing, a really huge benefit indeed, which you will get if you start using this tool: Docentric viewer actually works in on-premises environments! This is a truly useful because there is no viewer available for SSRS reports in D365FO on-premises environments. In fact, it seems that Microsoft has no plans to provide it at all, according to official documentation.













Docentric File Print Destination:

Besides sending files to browser for download, you can save files (also in batch) to Azure blob storage, SharePoint, Attachments or File system (applicable for on-premises). You can use placeholders in any of these settings, e.g. in Azure blob container or File system folder path.


Docentric Printer Print Destination:

Printing reports to a selected printer works in exactly the same way as the built-in functionality. The only difference is that you can set up the default printer (per user or user group).
























Docentric Print Archive:

Built-in Print archive contains archived reports that you can search by the Description field only (this data actually comes from report caption, e.g. ‘Show invoice’). Wouldn’t be great if we could search archived reports also by customer/vendor, Invoice ID, Sales/Purch ID, etc.? Even more, I would certainly like to see the email body of emailed reports including all the recipients (i.e. expanded email tokens), subject, etc. I was pleasantly surprised when I discovered that Docentric enables all of that.














In this article I made a short introduction of Docentric, a D365FO Add-On that significantly improves all report print destinations, especially emailing and archiving capabilities. It certainly helped me for my scenario, but more on that in my next article. 

Don’t forget, this tool is completely free! You can learn more about Docentric here: https://ax.docentric.com/free-edition/ 

Thursday 11 October 2018

Job to create prepayment against purchase order in D365

Vendor's prepayment in procurement process is a very common practice and in such scenario an organization should be able to track purchase order & their prepayments. In this blog I will discuss how can you create prepayment by X++ code in Microsoft Dynamics 365. Please find below screenshots.

Prepayment screen:













Source code of a method, which is breakdown in two images:


Image 1.1:

Source Code Explanation:
  • Get purchase order.
  • Initialize purchprepaytable buffer.
  • Set values.
  • For this example I have used prepayment type "Percent".

























Image 1.2:


Source Code Explanation:
  • Get purchase order total amount through PurchTotals class.
  • Run calculation of Purchase order total amount through calc() method.
  • Done calculation for Limit and available prepayment fields.
  • Set prepay category Id.
  • Insert record.











Job runs successfully.












Result:


Wednesday 10 October 2018

Performance timer in D365FO

In Microsoft Dynamics 365, Performance timer is a tool to quickly get an understanding off why our system might run slow. In order to check the performance we need to open the performance timer by opening our web page and add parameter debug=develop in the URL.

URL Example: https://yoursite.cloud.test.dynamics.com/en/?cmp=USMF&debug=develop





Note:
When you run in debug mode you will notice slower performance. You can quickly get an overview of most performance issues by pressing F12 and working with the debugging tools that are available in your browser. 

In order to open the performance timer window you need to click the timer.
























Here you can see three different tabs in which you can view the performance related statistics.

History Tab: It shows the number of calls occur opening a form. You can see the details by clicking the event showing in list.

Server Calls Tab: As its name describes, It contains the server call information.

Server Performance Counters Tab: In this tab there are four server performance counters that provides segregated server related information.



















Forms
: It shows how many forms are currently opened, opened/second, closed per second and a set of other counters like the total amount of created forms or closed forms.


























GC (Garbage collector): It gives you information about the garbage collection processes on the server.


























Web Client Session:
It tells you how many web client sessions you currently have and how many are in use.














Services Session provider:
This is the total amount of sessions created.














That is all, this screen will give you a head start in what to trace, where to start trouble shooting and what forms takes more time with client & server executions.

If you wants to read the Microsoft documentation at this topic you can read it through this link Performance timer.

Tuesday 9 October 2018

Import WBS lines in request for quotation lines in D365 through X++ code

Recently I have a requirement of importing the work breakdown structure lines on request for quotation lines as per associated project. So for achieving the requirement I have develop a job that can get the WBS lines and import those line on RFQ using AxPurchRFQCaseLine class. Please see below screenshots.

Work break down structure lines which needs to be imported:















Source code of a method which breakdown in three images:

Image 1.1:

Explanation of below source code image:
  • Initialize tables, class and edt buffers.
  • Get RFQ. (Here I have hardcoded RFQ Id)



















Image 1.2:

Explanation of below source code image:
  • Query to iterate smmActivityParentLinkTable table that contains the references to entities which are associated with an activity.
  • Sub query to iterate PSAActivityEstimates table that contains project quotation estimates.
  • Declaration of AxPurchRFQCaseLine class.
  • Set OOTB Parm methods of the class that can handle the given values.
















Image 1.3:

Explanation of below source code image:
  • Save method of AxPurchRFQCaseLine class that inserts the records also runs all the possible validations for request for quotation lines.













Result:


Monday 8 October 2018

Job to get vendor retention percentage as per project in D365

Suppose your organization might want to retain a portion of payments to vendors who work on projects for your organization. For example, you might want to make sure that the products from a subcontract vendor meet your expectations before you pay the vendor. For that need Microsoft Dynamics provides vendor retention process. 












In this blog I will discuss how we can get the vendor retention percentage by having project order id and vendor account. I have created a job to get the vendor retention percentage. Please see below image.

Method Explanation:
  • PSAVendorRetentionTermsLine table contains retainage schedules for project purchases.
  • ProjPWPVendorRetentionSetting table contains information about project-vendor PWP (Pay when paid) and vendor retention setting.
  • Get vendor retention settings by passing arguments.
    • Project Order Id
    • Vendor account
    • Account Code
  • Get retention term as per rule id got from vendor retention settings.



Result:








That is all, If you have any questions or queries do comment in the comment section below.

Override packing slip id while creating packing slip through COC in D365

In this blog we will discuss how we can override packing slip id by creating & posting packing slip through chain of command method.

Recently I have came across this situation in which I want to override packing slip id as per some conditions if it returns true while creating and posting the packing slip.

After some code debugging I have found that SalesPackingSlipJournalCreate class is responsible for creating and posting of Sales order packing slips. In this class we have a method initJournalHeader which is responsible to initialize packing slip header values in which packing slip id also initializes OOTB. 

So when I wants to copy post event handler of initJournalHeader method, it through me error because this method access modifier declare as Protected, so according to that it is not a hook-able method and we cannot create an event for the particular method.













Note:
I have written a blog to handle above error Technique to use Pre-Event Handler functionality for Protected Method in AX7 / D365 please refer.


In order to achieve my requirement I have used chain of command method as shown in below images.

Packing slip navigation:










Method which will do the magic:

Method Explanation:
1- I have created a class SalesPackingSlipJournalCreate_Extension.
2- Set attribute ExtensionOf and provide a class SalesPackingSlipJournalCreate.
3- Declare method to override the packing slip id.
4- Use next keyword create a Chain of Command for the method. CoC is a design pattern where a request is handled by a series of receivers. 
5- In this you have noticed I have declare CustPackingSlipJour buffer, the reason is in D365 it is a bug it cannot get the variable buffer directly from parent class, so for that I have to declare the buffer to get the value.
6- In the end I have simply assign my custom value of PackingSlipId.


















Result:











That is all, If you have any questions or queries do comment in the comment section below.

Tuesday 2 October 2018

Error the database could not be exclusively locked to perform the operation in D365

Recently I had a task to restore Microsoft Dynamics 365 database (AxDB), so for safe side I think I should keep my old database backup by only change it's name. When I done that error occurred that " Error: The database could not be exclusively locked to perform the operation" and it cannot let me rename the database as shown below.

When trying to rename manually it throws this error:


When trying to rename by SQL command it throws this error:











So after some research over internet I have found the reason and solution for this error. The reason of this error is that multiple connection is established with database that is why it cannot let me rename the database so in order to fix the issue I have to kill all the connections to the database. I use the ALTER DATABASE command to resolve the issue.

Solution:
  1. Set the database to single mode:
    • ALTER DATABASE YourDatabaseName
    • SET SINGLE_USER WITH ROLLBACK IMMEDIATE
  2. Try to rename the database:
    • ALTER DATABASE YourCurrentDatabaseName MODIFY NAME = YourChangeDatabaseName
  3. Set the database to Multiuser mode:
    • ALTER DATABASE YourChangeDatabaseName
    • SET MULTI_USER WITH ROLLBACK IMMEDIATE
Result:


Key Updates in Dynamics 365 F&O for Version 10.0.39

Here’s a concise summary of the  platform updates  in  Microsoft Dynamics 365 Finance & Operations version 10.0.39 (March 2024) : 1- Add...