January 25, 2015

South Asia MVP open day – 2015 @ Bangalore

DSC02825

Hi Guys,

So finally i was there @ Most awaited event of the year “South Asia MVP open Day” @ Bangalore. It was just AMAZING.. :)

We all had a great time, meet many senior MVPs, learned many new things with their experience.

Speaker Sessions were awesome. Inspired with each and every session.

Also feeling some stupidity why i didn't attend last year’s event, i missed that.  But now i am not going to miss any further events. :)

Thanks to Biplab Paul and Ghandharv for this whole event and great arrangement.

Thanks to all MVP ….

- Harry

January 20, 2015

New Certification on Dynamics AX 2012 R3 MB6-702 Microsoft Dynamics AX 2012 R3 Financials


Hi Friends

One new certification will launch soon on functional track.

Name: MB6-702 Microsoft Dynamics AX 2012 R3 Financials

Study Materials:
80651: Financials I in Microsoft Dynamics AX 2012 R3
80652: Financials II in Microsoft Dynamics AX 2012 R3
80653: Fixed Assets in Microsoft Dynamics AX 2012 R3
 
Wait i will share more details soon…. :)



Error:Failed to create a session; confirm that the user has the proper privileges to log on to Microsoft Dynamics

Error Message: Failed to create a session; confirm that the user has the proper privileges to log on to Microsoft Dynamics.

image

Solution: Delete AUC files and restart the services.





January 19, 2015

Run, Save and Email Purchase order report through X++ code

Sending SSRS Reports via Email in D365FO: Simplified Steps

Sending SSRS Reports via Email in D365FO: Simplified Steps

Introduction

In some cases, customers may require the ability to send SSRS reports directly to their email addresses, such as Purchase Order or Sales Order reports. In this blog post, we will demonstrate how to achieve this functionality using simple and straightforward steps.

Step 1: Running the Report and Saving it Locally as PDF

To begin, create a new class and add a method that runs the report and saves it to a local or shared path. Here is an example code snippet:

    
public str runAndSaveSSRSReport(PurchTable _purchTable)
{
    // Initialize variables
    SrsReportRunController ssrsController = new SrsReportRunController();
    PurchPurchaseOrderContract contract = new PurchPurchaseOrderContract();
    SRSPrintDestinationSettings printerSettings;
    VendPurchOrderJour vendPurchOrderJour;
    str reportPath;

    // Retrieve the latest purchase order for the specified PurchTable
    select firstOnly vendPurchOrderJour
        order by vendPurchOrderJour.createdDateTime DESC
        where vendPurchOrderJour.PurchId == _purchTable.PurchId;

    // Set the report path to save the PDF
    reportPath = "C:\\" + _purchTable.PurchId + ".pdf";

    // Configure the report controller
    ssrsController.parmReportName(ssrsReportStr(PurchPurchaseOrder, Report));
    ssrsController.parmExecutionMode(SysOperationExecutionMode::Synchronous);
    ssrsController.parmShowDialog(false);
    contract.parmRecordId(vendPurchOrderJour.RecId);
    ssrsController.parmReportContract().parmRdpContract(contract);

    // Link the printer settings to the controller
    printerSettings = ssrsController.parmReportContract().parmPrintSettings();
    printerSettings.printMediumType(SRSPrintMediumType::File);
    printerSettings.fileFormat(SRSReportFileFormat::PDF);
    printerSettings.overwriteFile(true);
    printerSettings.fileName(@reportPath);

    // Run and save the report
    ssrsController.runReport();

    return reportPath; // Return the file location where the PDF is saved
}
    
  

Step 2: Emailing the Report

Once the report is saved locally, you can proceed with attaching and sending it via email. Add the following method to your class:

    
public void POConfirmationEmail(PurchTable _purchTable)
{
    // Initialize variables
    PurchTable purchTable;
    Map parameterMap = new Map(Types::String, Types::String);
    Email requester;
    SysEmailId ApprovalEmailTemplate;
    SysEmailId ReopenEmailTemplate;
    str companyDetails;
    FilenameOpen attachmentFilename;

    companyDetails = curext();
    parameterMap.insert('CompanyDetails', companyDetails);

    purchTable = _purchTable;
    attachmentFilename = this.runAndSaveSSRSReport(purchTable);

    // Set email parameters
    parameterMap.insert('VendorName', VendTable::find(purchTable.OrderAccount).name());
    parameterMap.insert('PurchaseID', purchTable.PurchId);
    requester = LogisticsElectronicAddress::findRecId(DirPartyTable::findRec(VendTable::find(purchTable.OrderAccount).Party).PrimaryContactEmail).Locator;

    if (!requester)
    {
        throw error("No Email address is available");
    }
    else
    {
        // Send email using the "PoEmail" template and delete the report file after sending
        SysEmailTable::sendMail("PoEmail", companyinfo::languageId(), requester, parameterMap, attachmentFilename);
        this.deleteReportFile(attachmentFilename);
    }
}
    
  

Step 3: Deleting the Report File

Finally, add the following method to your class to delete the report file from the local drive:

    
public void deleteReportFile(str _reportPath)
{
    str reportPath = _reportPath;

    if (!reportPath)
        warning("No file in local drive to remove");
    else
        WinAPI::deleteFile(@reportPath);
}
    
  

Conclusion

By following the above three steps, you can easily send SSRS reports via email in D365FO. Consolidating the code into a single class enhances reusability and simplifies maintenance. Feel free to leave your feedback, questions, or queries in the comments section.

Enjoy the streamlined process!

- Harry

January 09, 2015

How to add new fields/Methods in Listpage from in AX 2012

How to add new fields/Methods in List page from in AX 2012
Here we use the Production Order list page for example
Open Production order list page from below link
Production control/Common/Production orders/All production orders
clip_image002
Now we need to add one new field “Serial Number” in this grid (Assuming there will be only one item in one Production order in every case).
This serial number is available in “Transaction” from of this production order.
Untitled
Now to display new fields you can add a new display method in table and drag-drop this method in a grid as a field.
Add one new method in “ProdTable” table add copy below code
display InventSerialId inventTransInventSerialId()
{
InventTransOrigin InventTransOrigin;
InventTrans InventTrans;
;
select InventTrans join InventTransOrigin
where InventTrans.InventTransOrigin == InventTransOrigin.RecId &&
InventTrans.ItemId == InventTransOrigin.ItemId &&
InventTransOrigin.ReferenceId == this.ProdId &&
InventTransOrigin.ItemId == this.ItemId;
return InventDim::find(InventTrans.inventDimId).inventSerialId;
}
Now set DataSource property of this new field as ProdTable. Save your from and compile for any error.
Now open this from, here is your from
clip_image008

-Harry