Have you ever found yourself in a situation where the Infolog keeps throwing up the same error / warning at you and you have no idea how to resolve it?
For example: "The field Foo must be set to Y to perform this action". That's a pretty clear message: you just have to set the Foo field to Y and you're good to proceed with what you were doing, except that you have no idea where the Foo field is! When I started working with AX, I found myself in this situation more than I'd like to, and it always annoyed me to have to call someone and ask where the damn Foo field was.
But sometimes, the Infolog would show me a magic button that would take me exactly to wherever I had to go to fix the error it was showing me. That magic button is called a SysInfoAction. For the example I have given above, if the good guy programmer had put a SysInfoAction on the Infolog, you could just click on a button and a form with the Foo field would pop up.
So how do you do it? Well, there are some different SysInfoAction types. Just to list a few of them:
- SysInfoAction_CostSheetValidate
- SysInfoAction_Editor
- SysInfoAction_Formrun
- SysInfoAction_MenuFunction
- SysInfoAction_newWindow
- SysInfoAction_Properties
- SysInfoAction_Showplan
- SysInfoAction_TableField
As you'd expect, each one of these classes exposes a different behavior when the user interacts with the button on the Infolog.
Let's take a look at the SysInfoAction_MenuFunction for example.
It does what the name suggests: adds a menu item on the Infolog. And it can be of any type: Action, Display or Output.
Suppose we want to redirect the user to a form so that he can fill in the "Foo" field:
SysInfoAction_MenuFunction sysInfoAction; sysInfoAction = SysInfoAction_MenuFunction::newMenuItem(menuitemDisplayStr(FooFormMenuItem), MenuItemType::Display); warning('The field Foo must be set to Y to perform this action', '', sysInfoAction);
Just by creating that object and passing it to the warning() method, you made the user's life a lot easier. There's also a constructor available to the SysInfoAction_MenuFunction where you can pass in the control's name of the form you're opening, and the framework will set the focus to that control if it's found on the form. Although it helps even more, the call to the method should be ugly, and easy to break, since there is no compile-time checking if the control actually exists on the form.
The good part though is that if the control isn't found, it just doesn't do anything.
But what about security?
I have to say that the security framework team did a tremendous job overall, and it's just the same with the SysInfoAction feature.
The SysInfoAction, in this case, is nothing more than a menu item. Menu items are bound with security objects in various ways, so it's kind of easy to get the related roles or duties. That being said, guess what happens if the user doesn't have the permission to run the MenuItem you have added to the SysInfoAction? The user doesn't see the button.
So if you're worrying that you might accidentally redirect a user to an important parameters form which he shouldn't have access to, don't worry, because you wont: the security framework will take care of that for you.
That all being said, I'd advise to always use SysInfoActions where it really improves the user experience.
No comments:
Post a Comment