Search This Blog

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

Hi Friends,

Sometime customer we face this requirement to send SSRS reports directly on emails of customer/vendor like Purchase order or Sales order report. In this post, I will demonstrate how to do these kinds of stuff in very easy steps, 





To understand each and every logic, we will perform this whole process in three steps. Let’s take an example of Purchase order report. 

1. Run a report and Save as PDF at local drive
2. Email this report
3. Delete from local drive after email.

It would be suggested to have all code into a single class than writing the code here and there on forms or any other standard classes. 

1.      Run a report and Save as PDF at local drive: 
Create a new class and add a new method for run a report and save it at your local/shared path. 

   public str runAndSaveSSRSReport(PurchTable _purchTable)
{
    SrsReportRunController          ssrsController = new SrsReportRunController();
    PurchPurchaseOrderContract      Contract = new PurchPurchaseOrderContract();
    SRSPrintDestinationSettings     printerSettings;
    VendPurchOrderJour              VendPurchOrderJour;
    str                             ReportPath;

    select firstOnly VendPurchOrderJour
    order by VendPurchOrderJour.createdDateTime DESC
    where VendPurchOrderJour.PurchId == _PurchTable.PurchId;

    ReportPath = "C:\\" + _PurchTable.PurchId +".pdf";
    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();
    //print to pdf and always overwrite if the file exists
    printerSettings.printMediumType(SRSPrintMediumType::File);
    printerSettings.fileFormat(SRSReportFileFormat::PDF);
    printerSettings.overwriteFile(true);
    printerSettings.fileName(@ReportPath);

    //run & save the report
    ssrsController.runReport();
    return ReportPath;// return the file location where pdf saved. we use this path to email and delete after email.
}

2.      Email this report: 
Now when we have report saved on local drive we can pick this file to attach in email. Add a new method in your class as below,





public void POConfirmationEmail(PurchTable   _PurchTable)
{
    PurchTable                  PurchTable;
    Map                         parameterMap = new Map(Types::String, Types::String);
    Email                       requester;
    SysEmailId                  ApprovalEmailTemplate;
    SysEmailId                  ReopenEmailTemplate;
    int                         itemCount = 1;
    str                         ItemId, ItemQty, ItemDeliveryDate, ItemPrice;
    str                         companyDetails;
    FilenameOpen                attachmentFilename;

    companyDetails = curext();
    ParameterMap.insert('CompanyDetails',companyDetails);
    PurchTable = _PurchTable;
    attachmentFilename = this.runAndSaveSSRSReport(PurchTable);

    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
    {
        SysEmailTable::sendMail("PoEmail", companyinfo::languageId(), requester, parameterMap, attachmentFilename); //PoEmail is emial template with two parameter (VendName and PurchId, you can make changes in template as per user requirement. 
        this.deleteReportFile(attachmentFilename);// To delete this file after email.
    }
}

3.      Delete report file from your local drive:
Now after email we have to delete this from memory, lets add one more method in your class to delete this file,

public void deleteReportFile(str _ReportPath)
{
    str         ReportPath = _ReportPath;

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

Now all you need is to call this class during confirmation of PO. Put your Feedback/question/Queries in comments. 





Enjoy......

-Harry


January 09, 2015

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

How to add new fields/Methods in Listpage from in AX 2012
Here we use 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 grid as 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