Wednesday, December 18, 2013

Cancel salesline in x++ code (including CW)

Cancelling an open salesline through code is a simple task.
When you're operating with catch weight items you need to include the CW remainder field.

The following code will cancel all open lines on a sales order that has been invoiced.
Don't forget tts.

    while select forupdate salesLine
    join salesTable
        where   salesTable.SalesId == "[Your SO]"
        &&      salesTable.SalesStatus == SalesStatus::Backorder
        &&      salesTable.DocumentStatus == DocumentStatus::Invoice
        &&      salesLine.SalesStatus == SalesStatus::Backorder
    {
        salesLine.RemainInventPhysical = 0;
        salesLine.RemainSalesPhysical = 0;
        salesLine.PdsCWRemainInventPhysical = 0;
        salesLine.Update();
    }


Friday, November 8, 2013

Parameter _reportName cannot be null or empty.

Recently came over a problem with running SSRS reports from AX 2012 (R2). This infolog error message was presented immediately when trying to run a report:

Parameter _reportName cannot be null or empty.
The [CLASSNAME].[METHODNAME]() reflection API could not create and return the SrsReportNameAttribute object.

In this specific case it looks like an earlier full compile did not finish.

If you encounter this problem I would suggest that you first compile the class mentioned in the error message and see if this solves the problem. Then you should schedule for a new full compile of the application.

Friday, June 7, 2013

AX World End Date

In some cases you will need to use the highest date available in a datetime field in Dynamics AX 2012.
Microsoft has decided that this date is:

December 31, 2154

Specifically when handling Date Effective Data in AX 2012, you might encounter date fields with the value "Never" when viewing it in the table browser. The field actually contains the date Dec 31, 2154.

When writing, updating or querying date effective records in x++, you can use the date 31\12\2154.
But a more accurate and less cryptic apporach would be to use the maxDate system function:

myDateEffectiveRecord.ValidTo = maxDate();