mfp's two cents

...on Dynamics AX Development!

  • mfp's two cents

    Microsoft Dynamics AX R3 is coming

    AX Logo

    Today is a big day for the engineering teams at Microsoft working on R3. We are reaching the important ZBB milestone. ZBB is one of the final internal checkpoints before releasing. It signals that there are zero active product defects known and planned for the release. Reaching ZBB is by no means an easy win. It requires maintaining a bug fix rate higher than the bug discovery rate for a lengthy period of time. It also requires significant coordination and team collaboration to have all teams reach this criteria at the same time.   

    One part of reaching ZBB is to have zero best practice errors across the entire code base. I’m happy to announce that R3 will ship with zero best practice errors despite the significant increase in code base.

    Once again; I’m awestruck by the energy, effort, diligence and dedication demonstrated by the Microsoft Dynamics teams to bring this important release to market.

    More to follow, as the release draws nearer…

  • mfp's two cents

    10 reasons I love my Microsoft Surface


    First things first – I work for Microsoft, and I will not claim to be unbiased. Yet, I bought my Surface out of my own pocket in a regular Microsoft Store – I was even in line for 3 hours to get it. Just like everyone else could.   

    Secondly, I primarily blog about AX – this is an exception, you don’t have to read it if you don’t want to.

    With the formalities out of the way, let me begin. I’ve had the device for about 1 year now. I wanted to use it primarily for entertainment – I did not go for any of the keyboard options. Let me share my experiences. 

    1. It is sturdy

    The Surface had not been in our home more than a few days when my 4 year old kid came running with it. He tripped over a toy, and the device came flying through the air towards our massive oak table. I’ve hit my toes many times on the table – always with the same result: Pain and Agony in well sized portions. Hearing the thud as the Surface collided with the table I closed my eyes. Game over. My kid was already crying. Bracing my self to clean up and comfort my kid – it was just a piece of hardware after all – I inspected the damages. The Surface was intact. I couldn’t even find the place where it had hit the table. It still worked flawlessly. The table – on the other hand – had lost a small chip of wood.  The small disaster turned into a simple “Ooops – up again!” situation.

    2. The kick stand

    First time I brought the Surface to some friends’ place, they said: “That is cool – how did you get that on your iPad?” I just smiled back.

    The kick-stand is amazingly pleasant as it allows for a much more convenient usage.

    3. User accounts and Picture login

    We have 3 users of the Surface. My now 8 year old girl and my now 5 year old boy – and myself. We each have an account, we each have our own apps, games and settings. I started out by just setting up one account, but quickly we ended up in situations where little-brother deleted (or moved) the games his sister liked. With 3 accounts that stopped right there.

    My 4 year old quickly learned how to login – just press your eyes and your nose. Had the system required a keyboard+password login it would have been usable for him.

    4. Family safety

    Both my kids accounts are monitored by the built in family safety feature in Windows 8. This means I get a weekly report showing how much they used the device and for what purposes.  And even better, the data is aggregated across all our Microsoft devices, so it also includes X-Box, the wall-mounted touch-all-in-one PC we have in the kitchen, and the regular workstation.   Here is a picture of some of the info the weekly report contains:

    The system is highly configurable – you can enforce time limits, ratings etc – you can even excluded some apps (like those used for homework) to count against the time limit.  As a parent I feel in control – without feeling I’m spying (too much)

    5. The modern UI.

    I simply adore the UI – the amount of energy that has been put into the aesthetic look of Windows 8 leaves me humbled. The result leaves me with a feeling of being spoiled. If you haven’t read the story behind the design – you should do so. The competition is ages behind.

    Every time I visit Bellevue Square Mall I visit the Mac store – just to see what is brewing. Since Windows 8 came out I’ve not been able to find anything that awakes the even smallest desire in me in Mac land.

    I find the same experience elsewhere too: In my pocket (Windows 8 phone), at work (Windows Server 2012), at my Laptop (Windows 8.1) and my X-Box (360 – soon to be One).

    The tiles are extremely powerful. They give me information at a glance - I don’t waste my time opening apps to check empty in-boxes.. The Data Sense App (on my phone) tells me my current network usage, the Stock portfolio App tells me how Wall-Street is doing, the weather app tells me the weather, the People app tells me if I have new messages aggregated across social networks, like Facebook, Linked-in. Without even opening a single app I get all this info. That is sheer power!

    6. USB

    The Surface has a USB port. This enables me to attach my Kindle to upload documents and charge. This enables me to attach a mouse and keyboard. This enables me to attach a printer. This enables me to attached a USB Drive. This enables me to attach my phone.

    What impresses me is that everything just works. All drivers are available for all devices even on Windows RT.   I have a Keyspan USB to RS232 – and even that highly specialized niche product has a driver on Windows RT. Connect and use.

    7. Skydrive

    When I’ve taken a picture with my phone, it is immediately available on my Surface. When my kids ask: “Can I see the pictures you took?” – we look at them on the Surface – it is better than on the smaller phone.

    Skydrive enables many other scenarios too – the one with pictures is my favorite.

    8. Desktop

    The Surface has a desktop – just like you know it from any other version of Windows. You can open File Explorer, Control Panel, Regedit, Task Manager etc. All the built in functionality of Windows is available.  And on top of that you get Office. 

    Some find it limiting that you cannot install 3rd party apps on the desktop in RT mode. This does not concern me. I actually try to install as few as possible across all my PCs – it just makes them easier to maintain and less subject to malware.

    9. Battery

    For the past year we have not had any problems with the battery life time. I’m not sure how many hours we get out of it, but it is never a problem. Not even on our 3 week vacation in car across Europe this summer.

    10. Microsoft Store

    There are plenty of apps and games – at least for my taste.  There are a few titles missing – but then again, there are also some exclusive titles – like FreshPaint.


  • mfp's two cents

    X++ Debugging Tips and Tricks #3–Conditional breakpoints


    The Dynamics AX Debugger doesn’t support conditional breakpoints. Once in a while this limitation can be quite annoying – but there is a simple workaround. The third trick in the series of X++ Debugging Tips and Tricks shows you how.

    This trick requires code instrumentation – I strongly discourage using this trick on a production system. Only use this trick in a test or development sandbox!        

    By using the breakpoint keyword, you can write X++ logic that triggers a breakpoint exactly as you want.

    Consider this example. It is a recursive implementation of the mathematical function: Factorial. On a 32 bit system it will overflow when called with a sufficient high value. The example shows how to a breakpoint when an overflow occurs.

        static void ConditionalBreakpointExample(Args args)
            int factorial(int _value)
                int result = 1;
                int prevResult;
                int i;
                for (i=1; i<=_value; i++)
                    result = result * i;
                    if (result < prevResult)
                        breakpoint; //Overflow occurred
    prevResult = result; } return result; } factorial(maxInt()); }

    The same approach can be used in many other scenarios too. Here is another example – I’d like a breakpoint to fire when a Released Product with Item Id “1000” is inserted in the database. To achieve that I add the following to the insert method on the InventTable table.

        if (this.ItemId == "1000")

    There is another way to achieve the same result. You can also insert a no-op line, like i=i; and set a normal breakpoint on that line using F9. This approach has the benefit that only the user setting the breakpoint will hit it – but at the risk of leaving some “silly looking code” behind. In contrast the breakpoint statement triggers a best practice error – so they are easy to clean out again.

    Bonus trick

    There is another usage of the breakpoint statement. Sometimes regular breakpoints in forms don’t fire – here the breakpoint statement also comes in handy. Instead of setting a breakpoint using F9 – just type “breakpoint;” in the code. This will trigger the debugger.

    This post is provided AS-IS, and confers no rights or warranties.

    X   Debugging banner 2

  • mfp's two cents

    AX 2012 R2 CU7 has been released!


    Cumulative Update 7 for Dynamics AX R2 has been released today!  Download it from Partner Source or Customer Source.

    Besides 60 country specific regulatory updates and many quality improvements, these areas have been enhanced:


    What’s new


    Accounts payable

    • New options for configuring workflows for vendor invoices.
    more info

    Accounts receivable

    • External documents can now be sent as email to a customer or vendor by using the email address that is specified by the address purpose field. Any report can be sent as email to an internal employee by using the worker title.
    more info


    • You can create a budget plan worksheet template for Excel by using a wizard in Microsoft Dynamics AX.
    • The budget allocation process is easier, because you can use ledger allocation rules for budgets.
    • Budget planning workflows can be set up so that they can’t be accidentally deleted or reset.
    • Budget planning workflows can be set up so that they require a parent budget plan.
    • You can specify whether budget planning user groups (XDS policies) are used for budget planning. You can also specify the number of associated budget plan lines to include when budget plans are exported to Excel.
    • You can view worksheet and justification documents from the Budget plan page in Enterprise Portal for Microsoft Dynamics AX.
    • The process of creating a budget plan from an existing budget plan is enhanced.        

    more info

    Fixed assets

    • You can now transfer more than one fixed asset at the same time.
    • The acquisition cost of fixed assets can include a miscellaneous charge amount.
    • The process for acquisition proposals or depreciation proposals for fixed assets can now be run in a batch process.

    more info

    General ledger

    • An Excel template for journal entries is included on the virtual machine for demo data.
    • More understandable posting messages for journal lines that have errors in the account combination.
    • Delete an unposted journal that contains lines.
    • View advanced rules for a main account.
    • Easier dimension setup for Excel integration.
    • Display dimensions in a specified order in Management Reporter.

    more info

    Human resources

    • New preparation reports available to help make it easier for employers to complete mandatory human resource reports.
    • Changes to the forecast positions area .
    • You can require additional details when worker information is entered or changed, and optionally enable workflow.         

    more info

    Inventory and warehouse management

    • New On-hand entries cleanup batch job can be used to delete unused entries for serialized on-hand inventory, helping to improve the performance of queries for on-hand inventory.
    • You can combine two or more inventory batches into a new or existing batch.
    • Added new Role Center for costing and inventory valuation.

    more info


    • You can mass update benefit rates for workers.
    • Tiered contribution calculation rates for retirement benefit plans.
    • Create and update payroll tax groups.
    • Preparation of regulatory compliance reports for payroll.
    • Separate positive pay statements for Payroll bank accounts.

    more info

    Procurement and sourcing

    • Financial dimensions can be specified on sales agreements or purchase agreements.
    • A Totals FactBox is added to the Purchase orders list page.

    more info

    Product information management

    • You can determine prices using a product configuration model.

    more info

    Production control

    • Case management functionality is enhanced for documenting and releasing product changes to production.

    more info

    Project management and accounting

    • Use Microsoft Project to create or update a Microsoft Dynamics AX project plan, and integrate with an Office 365 SharePoint project site.
    • Use Microsoft Project to create or update the work breakdown structure (WBS) for a Microsoft Dynamics AX project quotation.
    • Create a WBS template for Microsoft Dynamics AX by using Microsoft Project.
    • Expanded support for working with project teams, defining project role types, and managing projects.
    • Expanded support for managing worker assignments and capacity in projects.
    • Enable audit trails on timesheet entry and reporting.
    • Improved management of project tasks in a WBS.
    • Improvements for creating WBS templates for project tasks.
    • Intercompany pro forma invoices for project costs.

    more info

    Public sector

    • The configuration keys for public sector organizations in France are enabled by default, hence the primary address of the organization no longer has to be in France if you want to use the French public sector accounting rules.
    • You can now dispose of more than one fixed asset at the same time.

    more info


    • Prompt for a reason code when the cashier opens the cash register drawer without performing a sale transaction.
    • You can post store transactions from statements based on the end of the business day instead of the calendar day.
    • You can use a new statement method to calculate statements by shift.
    • Passwords can now be changed and reset in Microsoft Dynamics AX for Retail POS.
    • Cashiers can view additional customer account information in Retail POS.

    more info

    Sales and marketing

    • You can calculate the sales price of an item by using an attribute-based pricing formula.

    more info

    Backup and recovery

    • We have added functionality for backup and recovery for cumulative update 7 for Microsoft Dynamics AX 2012 R2.

    more info

    Data import, export, migration

    • As of CU7, the Data Import/Export Framework is shipped as part of AX instead of as an add-on.

    more info

    Office Add-ins

    • Improved performance when you use the Office Add-ins. A new Validate dimensions button helps you locate and correct financial dimensions that were entered incorrectly or that are suspended.

    more info


    • PowerShell commandlet to install multiple instances of SSRS on the same SQL server
    • SSRS is primed after restart to speed up "first time" execution of reports
    • Can send reports to people using a token (@<Job Title>@) instead of being forced to name people explicitly
    • MorphX compare tool enhanced to support reports
    • Management Reporter can now be installed with primary AX setup

    more info

    Sales tax processing

    • Sales taxes and ledger accounts can be reconciled more easily.
    • Performance is improved for tax reporting.
    • You can post of sales tax amounts for intercompany transactions to either the source legal entity or the destination legal entity.

    more info

  • mfp's two cents

    X++ Debugging Tips and Tricks #2 – xSession::xppCallStack()


    X   Debugging banner 2

    In the first trick we saw how to set a breakpoint in the add method on the info class. This enables us to get the context of a single error.   But sometimes error messages come in hoards and stepping through each of them is not practical. Suppose you have hundreds or even thousands of errors occurring, and you want to trace where they are coming from. This trick shows you how.

    This trick requires code instrumentation – I will strongly discourage using this trick on a production system. Only use this trick in a test or development sandbox!        
    The system APIs available in Dynamics AX are fantastic. There is hidden gem of an API that gives access to the current X++ call stack in the form of a container. This makes it relatively simple to include the call stack in the error messages shown in the Infolog. Just insert this line of X++ code in the add method in the info class just after the variable declaration section:

    _txt += con2Str(xSession::xppCallStack()); 

    Now run the scenario, and inspect the Infolog. It will include the call stack for each message, and will look something like this:


    With this information it is much easier to browse through the many messages in the Infolog and find variations in the call stacks.

    This post is provided AS-IS, and confers no rights or warranties.

  • mfp's two cents

    X++ Debugging Tips and Tricks


    X   Debugging - Full 2

    I hate debugging - I would much rather write code or watch tests execute! Debugging is a waste of time, and often follows an unpredictable path.

    Any developer knows the situation: A bug is discovered, and the cause must be found. Most developers have these war stories on how they fought with a bug. The battle swung back and forth. Theories were tested and discarded, instrumentation was built, log files were examined, Murphy visited and, coffee was spilled. When the stories are told, they typically have a happy ending, so eventually the Eureka-moment occurred and the cause was found. And a debugging lesson was learned.

    One of my toughest debugging session spanned almost 2 weeks. My code was complete and ready for check-in. I had worked on it for about 2 months in a private branch. Before reverse integrating into the main branch I ran all unit tests. A successful run takes about 12 hours. In my case the execution crashed after about 10 hours. I tried to run the single test case that crashed in isolation. It passed. I tried again with the full automation. It still crashed. I then tried disabling the crashing test, just to realize 10 hours later, that now a different test crashed. I then tried running with a debug version of AX32, so I could debug the crash. But the debug build is much slower, so it would take ages before the crash happened. So I needed to isolate the crash in a simpler repro. I tried changing the order of tests, and with every change I made the crash moved somewhere else. I then began trawling the system logs for information about the crash. This lead me to think about memory – perhaps something was leaking memory. I instrumented the test automation, so it would dump the current memory footprint every 10 seconds to a log file. And yes – memory consumption climbed until the crash occurred. But hey; I’m just writing X++ code – what can I possibly do that causes memory to leak? Driving home one day I got the idea that perhaps it was not my code, but the X++ runtime. After all; I was using some of the not-yet-released-at-this-point X++ features pretty heavily (attributes and events). So I wrote a small job, that exercised these areas heavily, and I saw memory climbing slowly but steadily until the crash. Now with a simple repro in hand, it was not hard to solve the issue – but I did require help from my friends in the X++ team. Two weeks had passed before I was ready to submit, my code was exactly the same, and now all test passed.

    This X++ debugging series of posts is dedicated to share X++ debugging tips and tricks. Having a toolbox full of different ways to attack bugs is required to be a productive developer. I’m going to share some of my tricks. If you have tricks of your own, please write a comment, and I will include them in the series. The ultimate goal is that we all efficiently find and solve X++ bugs.

    Trick #1 – Breakpoint in Info.add()

    Trick #2 – xSession::xppCallStack()

    Trick #3 – Conditional breakpoints

    Trick #4 – Reading uncommitted data

    Trick #5 – To be announced

  • mfp's two cents

    X++ Debugging Tips and Tricks #1 – Breakpoint in Info.add()


    This trick is probably the first every X++ developer learns, so it deserves to be the first on the list of X++ Debugging Tips and Tricks.

    Suppose an X++ exception occurs and you want to know why. The error is written to the Infolog. Double-clicking the line in the Infolog window will bring you to the line that threw the exception. Sometimes it is trivial to see the cause just by looking at the code. Other times it is not, and you will need the entire context including the call stack and variables to figure out what the cause is.

    Set a breakpoint in the add method on the Info class – and rerun the scenario. When the exception is thrown your breakpoint is hit, and you can perform the autopsy.


    This post is provided AS-IS, and confers no rights or warranties.

  • mfp's two cents

    Item tracing functionality in Microsoft Dynamics AX 2012 R2 CU6


    I recently joined the A SCM Inventory team at MDCC – so let me direct your attention to a significant improvement in CU6 in the Inventory area.

    Please follow this link:

  • mfp's two cents

    Microsoft Dynamics Lifecycle Services is Live



    Microsoft Dynamics Lifecycle Services are designed to manage and optimize customer implementations – powered by Azure. The customer creates project workspaces for implementation, upgrade and maintenance activities, and will invite implementation experts from partner organizations and Microsoft into these workspaces for the execution of related activities. Partners will be able to create projects for learning and presales purposes. This enables partners to build out expertise around Lifecycle Services, and demonstrate this in sales cycles.


    Take it for a test drive @




    • Customer-managed collaboration workspace
    • Cloud-based, secure environment
    • Project management using SureStep or other methodologies
    • Project-specific dashboard
    • Tools & data that connect multiple lifecycle phases to enable better decision making by key stakeholders

    Business process modeler

    • Aligns industry processes (APQC) with process maps for Microsoft Dynamics AX.
    • Create cross-functional flowcharts based on rich metadata.
    • Map processes & perform fit-gap analysis.
    • Integration between BPM & RapidStart.
    • Quickly generate documents and flowcharts using TaskRecorder (KB#2863182).


    • Leverages a cloud-based rule engine to analyze code and identify potential best practice, performance and upgradeability issues.
    • Generates actionable reports in Excel & HTML that can be imported into MorphX IDE as actionable to-do’s for developers.

    License sizing estimator

    • Estimate how many licenses you need (CAL)
    • Model the effect of custom roles on license needs.
    • Get automatic CAL-level estimates


    • Model user & batch AX loads.
    • See graphic representation of load volumes.
    • Identify a starting point for infrastructure sizing.

    Issue search

    • Search a repository of reported, in-progress & fixed issues.          
    • Identify specific code objects & lines of code affected by hotfixes.
    • Get notifications for issue state changes, and new fixes for AX functional areas.


    • Automate & monitor health checks for AX ecosystem.
    • Collect data from AX environments.
    • Evaluate data against pre-defined rules & health checks.
    • Generate reports to provide monitoring & actionable corrective action summaries.

  • mfp's two cents

    Debug::Assert in X++


    Update 4th of August 2014: Clarification of the AX runtime behavior when non-developers hit an assert statement.

      defect free software

    “In computer programming, an assertion is a predicate (a true–false statement) placed in a program to indicate that the developer thinks that the predicate is always true at that place.”

    What would you rather have: A piece of source code with or without assertions? I’d definitely prefer source code with assertions – it makes the code easier to read, debug and troubleshoot.

    My recommendation is to use assertions in X++ when all of the following are true:

    1. The condition can never be false if the code is correct, and
    2. The condition is not so trivial it obviously be always true, and
    3. The condition is in some sense internal to the component, and
    4. The condition can be verified without any method calls.


    1. The condition can never be false if the code is correct

    Assertions and error handling are two different things.

    • Assertions should be used to document logically impossible situations in a correctly implemented program. If the impossible occur, then something is wrong – a programming error has been discovered.
    • Error handling – as the name implies – is the implementation of what should happen when an error occurs. Error handling are valid code paths that determines how the software reacts to various erroneous conditions, like incorrect data entered by the user, to system error conditions like out-of-memory.

    In a nutshell, it should be possible to write unit test for error handling – but not for assertions.

    2. The condition is not so trivial it obviously be always true

    Assert statements takes time to write and read – and if the condition they are asserting is obviously always true, then the assertion is pure clutter – and we are better off without it.

    3. The condition is in some sense internal to the component

    A failing assertion is an indication of a problem with the implementation. Something within the component – regardless of input from the outside world – is broken and needs fixing. Typically, I’d use assertions for input validation in private methods, and exceptions in public methods. Conversely, you don’t want consumers of your component to be hit by assertions – regardless of how they use your component.

    4. The condition can be verified without any method calls.

    Assert statements in X++ are a little special, as the X++ compiler always includes assert statements. In other languages (like C#) you can have multiple compiler targets – and typically the release build would not include the assert statements. In AX when a non-developer is hitting an assert statement, then the runtime will suppress eventual errors. I.e. in a production system assert statements have no functional impact.

    Given assert statements in X++ are always evaluated, and thus degrades performance, they should be used with a bit of caution. If the condition can be verified with minimal overhead – for example that a variable has a certain value – then there is no problem. However; if the assertion requires execution of complex logic, RPC or SQL calls then it should be avoided, due to the performance impact. In cases where the performance impact is significant, but you don’t want to compromise on assertions, the assertions can be wrapped inside a call to Debug::debugMode().

    “without any method calls” is just a guiding principles. Sometimes it makes sense to factor the condition into a Boolean method – for reuse or for clarity – here I would not object.


    Here is an example of good use of assertion in X++:

    private void markDetailRecordAsEdited(
    RecId _journalControlDetailId,
    RecId _draftConstraintTreeId) { Debug::assert(_journalControlDetailId != 0); Debug::assert(_draftConstraintTreeId != 0); if (! modifiedDetailRecords.exists(_journalControlDetailId)) { modifiedDetailRecords.insert(
    _draftConstraintTreeId); } }


    Here is another example where Debug::debugMode() is used:

    private void render()
        if (Debug::debugMode())
            Debug::assert(this.hierarchyCount() > 0);
            Debug::assert(segments != null);
            Debug::assert(totalSegmentCount > 0);

    Closing remarks

    I once saw a t-shirt with this print on the front: “If debugging is the process of removing bugs, then programming must be the process of putting them in”.  I wish the back had read: “Programming with assertions is one way to keep bugs out.”

Page 3 of 20 (195 items) 12345»