As I started to find out how to remove Hide and Setup from right click. I came to know that these are somewhere in base classes that are not accessable in Axapta. Setup however can be controlled by assigning Security Keys to "SysSetupForm" and then using the security framework to restrict access to this setup form. But I can't find any way to do the same with the Hide functionality. With a little more research I came accross "SysSetupFormRun" class. This class has a very intresting method called "task". Here we can tap into the task that are available from the right-click in a form and do whatever we like with it.
After looking at the task method in SysSetupFormRun, I found out that there is a "Task" macro that hold all the enum for different tasks. So I modified these two piece of code and was able to stop users from using Hide and Setup. Following is the code that I modified.
In AOT->Macros->Task add the following code
#define.taskFilterSetup(2847)
#define.taskFilterHide(2848)
In AOT->Classes->SysSetupFormRun->task add the following code public int task(int _p1)
{
#task
FormDataSource formDataSource;
int ret;
if (_p1 == #taskFilter)
{
formDataSource = this.objectSet();
if (formDataSource &&
formDataSource.queryRun() &&
formDataSource.queryRun().args() &&
!formDataSource.queryRun().args().caller())
{
formDataSource.queryRun().args().caller(this);
}
}
// code change begin
if (_p1 == #taskFilterHide or _p1 == #taskFilterSetup)
{
return 0;
}
// code change end
ret = super(_p1);
return ret;
}
This will still show Hide and Setup tasks in right-click menu on a form but nothing will happen as the user clicks on it(not the proper way but it solves the problem).
Note: This will disable these tasks for all users, you can code it to be available for a user group and not available for others.
This posting is provided "AS IS" with no warranties. Use code at your own risk.
No comments:
Post a Comment