Hi All,
I use treenode class creating table at run time, everything works well. Unfortunately, only users in sys admin role can execute the class. For other roles AX throws error said “Unable to save . Access Denied: You do not have sufficient permissions to perform the requested operation.”. I found an article about treenode class at https://msdn.microsoft.com/en-us/library/gg958198.aspx which mention “This class, and the classes that extend it, enable you to create, read, update, and delete X++ code and metadata. Make sure that the user has access to the development security key (SysDevelopment) before calling this API or APIs that are derived from this class.”. Unfortunately again, security key is not available in AX2012 R3.
Please let me know what should I do to allow users in other roles execute the class. Many thanks.
Regards,
Hung
You need development permissions for development, such as creating new tables, which means being member of System Administrator role. It shouldn’t be any problem for developers in development environments.
If you want to do such things in production, just don’t do it. You really don’t want users meddling with production database, synchronizing database during working hours and so on.
Hi Martin,
Thanks for the reply, I really need to allow user run treenode class because the code creates table and form dynamically based on transactions. Fields in table and form are not fixed. I tried the RunAsPermission class but faced alot errors and issues so I gave up trying the class. Please advise if there is any better approach resolving the issue. Many thanks.
Regards,
Hung
I might be able to suggest a better design, if you explain your underlying business requirement. If you insist on this particular implementation, I’m not going to assist you, because I think it would ultimately cause you more problems than it solves.
Hi Martin,
I want to build a form at run time because fields are not fixed for example, the columns are the item id from cusinvoicetrans table. This form aggregates invoice quantity of items from invoices. I can only think of using treenode to overcome this request. If there is any better approach please share.
Regards,
Hung
There are many ways how to create dynamic forms. For example, the table browser is just a normal AX form and it shows different fields every single table.
And even if you wanted to create a form at runtime, it’s a completely different question than changing and synchronizing database schema at runtime.
Hi Martin,
Creating form and fields dynamically is not a problem. The problem is users not in admin role cannot execute the code. This issue causes a lot headache. If there is any sample code please share. Many thanks.
Regards,
Hung
Sample code for what? If you want see table browser, you’ll find it in AOT (Forms >SysTableBrowser). It obviously don’t waste resource by creating a new form every single table; it merely add controls at runtime as needed. Because there is no code generation at runtime, everybody can use table browser without development permissions.
You should avoid code generation and do something similar to table browser.
Hi Martin,
Let me look at SysTableBrowser form. Thanks for the advice.
Regards,
Hung