Dynamics AX: Turning off specific tasks

Recently I had a someone ask me how to turn off or disable the Export to Excel task. Unfortunately, like most tasks, it can't be disabled via the options dialog like the Document handling subsystem can be (Tools/Options/General/Miscellaneous/Document handling active).

In the AX2012 client, the task keyboard shortcuts like Ctrl+T don't go through the buttons, so disabling the Export to Excel button on a form doesn't affect keyboard shortcut access (or File menu access) to the Export to Excel task. However, each task does go through the task method. You can override the method to deny any task if wanted. And Class:SysSetupFormRun gives you cross cutting coverage across all forms where you can deny certain tasks by not calling through to super().

For example the following code would cause the Export to Excel task to be ignored:

public int task(int _p1)
    int ret;

    if (_p1 == #taskExportExcel)
        //Check for permissions if desired
        //Ignore Export to Excel task
        return 0;
//...other code here...
    ret = super(_p1);
    return ret;


Of course I wouldn't recommend taking valuable options like Export to Excel away from users, but if you have specific requirements for the task subsystem it is useful to know how to influence it at such a low level.