Friday, December 11, 2015

Cross-Company-External record context

I faced a situation where I had to convert a listpage to cross company in EP. So I changed the query and redeployed. Pretty easy stuff. But then on clicking the record it opens a web control for approval and same thing happens with a button in the toolbar above. So in the case of cross company the web control was getting displayed blank as it wasn't getting the record context.

So I was able to handle the toolbar button by changing it's property "External Record Context" but couldn't handle the record link (HyperLinkButton). I tried getting the record context using IAxaptaAdapter but it didn't seem to work. :(


Wednesday, December 2, 2015

Cheque Report in Ax2012

Classes related to the Cheque report:
http://dynamicsuser.net/forums/p/59551/319006.aspx

https://stoneridgesoftware.com/dynamics-ax-development-check-basics/

Tuesday, December 1, 2015

Manually generate Number Sequence & release unused

The below code is to manually generate the number from the Number Sequence code:

numberSeq = NumberSeq::newGetNumFromCode(BankAccountTable::findByLedgerDimension(this.OffsetLedgerDimension).FundsTransferRefNum);

Sometimes we face this situation where number sequence doesn't release the unused numbers even if the Number sequence is configured as "Continuous". In that case we can use the below code:

NumberSeq::releaseNumber(NumberSequenceTable::findByNaturalKey(BankAccountTable::findByLedgerDimension(this.OffsetLedgerDimension).FundsTransferRefNum).RecId, ledgerJournalTrans_FundsTransfer.FundsTransferRefNum);

Conditionally hide Report Viewer buttons Ax2012

Today I was stuck in a situation where I had to disable the export button on the report viewer if the journal is not posted. After googling I got the below code which sits on the SRSReportViewer form:

private void hideExportButton()
{
    System.Windows.Controls.UIElementCollection elementLocal;
    Microsoft.Reporting.WinForms.ReportViewer   reportViewer;

    elementLocal = _AxReportViewer_Control.get_Children();
    reportViewer = elementLocal.get_Item(0);
    reportViewer.set_ShowExportButton(false);
}
Credit: http://www.agermark.com/2014/12/hide-export-button-from-report-viewer.html

You should have either different designs or menuItems for each condition to be called on the "init" method of the "SRSReportViewer" form. Add your custom code to call the hideExportButton where "_AxReportViewer_Control" is initialized.

// In case of multiple designs
    if(this.controller().parmReportName() like "*FundsTransferNoExport*")
    {
        this.hideExportButton();
    }
// In case of multiple menuitems
    if(this.args().menuItemName("*FundsTransfer*"))
    {
        this.hideExportButton();
    }