Search This Blog

Tuesday, 17 March 2020

Adding Subject and Body to the report send in an email by using the Print Management in D365 for Finance and Ops

As you already know there are standard AX Documents that you can print or send in an email using print management destination settings.

By using the below configuration in print management settings.



























But the problem is once you receive the document in an email that was sent through print management. It does not contain any user-friendly subject or body of the email.

Like this:










There was the requirement to include the Subject and Body to the email that is sent through print management.

For this what we did we created a parameter where we set up the email template and inside that email template, we specified the subject and email body.














below is the code snippet that we have used:

/// <summary>
/// Extension for class <c>PrintMgmtReportRun</c>
/// </summary>
[Extensionof(classstr(PrintMgmtReportRun))]
final class FBHPrintMgmtReportRun_Extension
{
    /// <summary>
    /// COC for SettingDetail method
    /// </summary>
    /// <returns></returns>
    public PrintMgmtPrintSettingDetail settingDetail()
    {
        PrintMgmtPrintSettingDetail     currentSettingDetail;
        currentSettingDetail = next settingDetail();

        if (this.parmDocType() == PrintMgmtDocumentType::VendPaymAdvice
            || this.parmDocType() == PrintMgmtDocumentType::CustPaymAdvice)
        {
            SRSPrintDestinationSettings printDestinationSettings;
            printDestinationSettings = currentSettingDetail.parmPrintJobSettings();

            if (printDestinationSettings.printMediumType() == SRSPrintMediumType::Email)
            {
                SysEmailId              sysEmailId;
                SysEmailTable           emailTable;
                SysEmailMessageTable    emailMessageTable;
                FBHVendParametersExt        vendParameters;
                FBHCustParametersExt        custParameters;

                if (this.parmDocType() == PrintMgmtDocumentType::VendPaymAdvice)
                {
                    select firstonly PaymAdviceEmailTemplateId from vendParameters;
                    sysEmailId        = vendParameters.PaymAdviceEmailTemplateId;
                }
                else
                {
                    select firstonly PaymAdviceEmailTemplateId from custParameters;
                    sysEmailId        = custParameters.PaymAdviceEmailTemplateId;
                }

                emailTable        = SysEmailTable::find(sysEmailId);
                emailMessageTable = SysEmailMessageTable::find(sysEmailId, emailTable.DefaultLanguage);

                printDestinationSettings.emailSubject(emailMessageTable.Subject);
                printDestinationSettings.fbhEmailBody(emailMessageTable.Mail);
            }
        }
       
        return currentSettingDetail;
    }


}

now after doing the above change when you try to receive the report in an email that was sent through print management then you will receive the like this which contains the subject and body as well that you have set up in email template.



Monday, 10 February 2020

Queries on Valid Date Time State Tables

Some tables in Ops have valid time state enable like the below example on hcmemployment table:










in order to find a valid record in this kind of table, a simple select statement is not what you have to use.

you have to provide the date range "from" and "to" to see is the record is exists in these date ranges or not.if it exists then its a valid record and if it does not exist then it's not a valid record irrespective of either record exists with other date ranges or not.

For more details, you can check the hcmworker.isEmployee method.

Thanks,
Zahid


Tuesday, 6 August 2019

Installing printer on One Box Dev in D365 for Ops


Installing Network Printer on One Box Environment.

Below are the steps to install network printer on your machine if you want to print document or SSRS report directly to the Printer.

Navigate to Organisation Administration -> Setup -> Network Printers













Download this software and then install it.

After the installation open your document routing agent.

Go to the settings and then set the Azure AD Tenant, your Dev Box URL in Dynamics 365 URL textbox and check the the checkbox enable logging view in application and then press ok
















After that go to the printer tab and select the Printer which you want to use to Print your documents.

Note: Sometime your desire printer won't appear in the list of printers that are showing. In that case you need to install that specific printer first by going to the Control Panel and Printer and settings.

































Here in above image you can see that many Printers are appearing and I have selected one on which I have to do the testing. You can select multiple printers as well.

Once you select the printer and press the register button then that specific printer will appear in the list of registered printers on the following navigation.

Organisation Administration -> Setup -> Network Printers


















Now I will show you while printing the SSRS report when I select the Print destination Printer instead of the screen then the above printer will appear on the available list of printers.







































For more details below is the link from Microsoft:


Monday, 5 August 2019

An error occurred rendering the report. Accessing the report server URL caused an error. The remote server returned an error: (500) Internal Server Error.


We have to customize the transfer order shipment report in Microsoft Dynamics D365 for Operations and while running the report if we sent the report directly to the printer instead of printing on the screen we were getting the following errors.


" An error occurred rendering the report. Accessing the report server URL caused an error. The remote server returned an error: (500) Internal Server Error."





















In the initial investigation I thought there is some issues on the printer cause the report was working fine when I set the printer destination on screen.

But after some research I found below link where its mentioned to check the SSRS logs.


Below is the link where can see the details of how to investigate the SSRS logs.



On the above link I found the navigation to open the SSRS logs.













I tried to open the latest log file in note pad and try to found the text with keyword "error" and found out below.






The Problem was I have created parameter name "inventTransferId" in my contract class and I set it to hide on report level but the problem was its value was not initialised when I was trying to send the Report Directly to Printer.


When I set the following property of the of the parameter then my report was working fine.




Thursday, 2 May 2019

Monday, 4 February 2019

D365 for Finance and Ops X++ Job to Get the Primary Position Title of Employee by Passing Worker Recid

Below is the code snippet to get the Primary Position Title of the employee by passing the worker recid.


private HcmTitleId getPositionTitle(HcmWorkerRecId hcmWorkerRecid)
    {
        HcmWorker                   hcmWorker;
        HcmPositionWorkerAssignment hcmPositionWorkerAssignment;
        HcmPosition                 hcmPosition;
        HcmPositionDetail           hcmPositionDetail;
        HcmTitle                    hcmTitle;

        hcmPositionWorkerAssignment = HcmWorkerHelper::getWorkerPrimaryPositionAssignment(hcmWorkerRecid);
       
        select TitleId from hcmTitle
            join hcmPositionDetail
        where hcmPositionDetail.Title == hcmTitle.RecId
            join hcmPosition
            where hcmPosition.RecId == hcmPositionWorkerAssignment.Position;
       
        return hcmTitle.TitleId;
    }

Note that HcmPositionWorkerAssignment is a validTimeState table. The above query will only retrieve position assignment that is currently active. 
This posting is provided "AS IS" with no warranties, and confers no rights.

Thanks,
Zahid

Wednesday, 7 November 2018

Purchase Order Confirmation Report in Dynamics D365 for Finance and Operations

There are three types of Purchase Order Reports you can generate from Ops.

1. Purchase Order Confirmation.

2. Purchase Order Invoice.

3. Purchase Order Product Receipt.

In this Post, I will talk about only Purchase Order Confirmation Report and this post is basically related to the Configuration that we can enable and disable in the Purchase Order Confirmation Report.

First of all, I will show how to generate the Purchase Order Confirmation Report.

Below are the steps to generate the Purchase Order Confirmation Report.

Go to Accounts Payable -> Purchase Order -> all Purchase Orders.











Select the Purchase Order that is already Approved and then select Confirm button under Purchase Tab in the action section.














Once the Purchase Order is confirmed then its status will be changed to "confirmed" and the "Purhchase order confirmation"  button will be enabled under Journals section in Purchase Tab










Once you click that button a new form will open which contains the versions of this Purchase Order.















Click the Preview/Print button and select the option you want to print the report. if you want to print copy than select copy preview. if you want to print original then select original preview or if you want to use print management settings then use the select the Print Management.

I select the Orginal Preview.

Now Below is the output of the report.



























Now the above steps were related to generating the Purchase Order Confirmation Report.
There are some areas that I have highlighted in the above image. Values of these fields you can change at any time without the customization.

As you can see point 1 in the highlighted area is related to the Company Address, Telephone, Fax, Giro, Tax Registration Number.

These bits you can configure and change at any time. Below are the navigation and screenshot of the form where u can configure company address, telephone, fax etc.

Go to Organisation Adinistration -> Organisation -> Legal Entities

Select the record which is in your log in a company. In my case, it's in usmf.












as you can see in the above image I have highlighted the Address and Contact Information tabs.

In these tabs, you can configure the addresses and contact info. you can add multiple records as well but the records which are set to primary will appear on the PO Confirmation Report.

Now the second thing that I have mentioned in the report are the external header and line level notes that you can set up in Purchase Order Report.

First I will show how you can create header and line level external notes.

Open your Purchase Order Form like the one below:









Now click on the Purchase Order Header Button as highlighted above. Its color will change to blue as you can see in the above image after that click on the attachment button this is also highlighted in the above image.












Now as you can see once you click on the attachment a new screen is open where u can setup notes.

Just create the notes of type "Note" and then set the note text under notes section and set the Restriction to "External".

Note: if you set the restriction to internal than notes will be printed on PO Confirmation Report as internal notes are for internal use only. They are not for reports.

After that close that form and go back to the Purchase Order and then click on the lines and then click the attachment button.

The same new form will be open where you have to set up the External notes for lines.










As you can see in above image create the notes of type "Notes" and set the notes for line level external notes and then set the restriction to external.

Again just mentioning only external notes will appear on the report if the restriction is internal then notes will not appear on the report.

This was all for setting up the external notes. Now I will show you how you can set the configuration to show and hide these notes on PO Confirmation Report.

Just go to the Procurement and sourcing -> Setup -> Forms -> Form Setup












The two drop downs I have highlighted in the above image. First one is related to select to show either header level external notes or line level external notes or both or none of them.

The second drop down is related to the which type of Note you want to show. By default the notes type is Note.

Now the point number three that I have mentioned in the report is the external item number. That you can also show and hide.

On Purchase Order Line Details under the general tab, you can set up your external items number. Mentioned below for reference.












To show and hide this external item number on the report below is the navigation to the configuration form.

Just go to the Procurement and sourcing -> Setup -> Forms -> Forms Stup

 The drop i.e ITEM NUMBER that I have mentioned in the above image.if you set this to both than external item number will be visible on the PO Confirmation Report.

Now the fourth and the last thing that I have highlighted in the PO Confirmation Report is the Form Notes.

You can set up these form notes on the following navigation.

Procurement and Sourcing -> Setup -> Forms -> Form Notes

Select Purchase Order and then specify the notes.













if you don't specify any text on the form notes then nothing will be displayed on the purchase order confirmation report.

This was all related to the PO Confirmation Report. Feel free to Comment if you have any questions.

Thanks,
Zahid