How to determine whether a user has permissions to update a table using business connector

1.3k Views Asked by At

We are developing an intranet application using the Business Connector with our Dynamics AX 2009 installation.

We want to allow users to update the data from certain tables if the user already as permission to do so in AX. That is, if the user's effective permissions would allow them to update data using the AX Windows client, then they should be able to update the data using the intranet application.

We are using the LogonAs method and passing in the current user's logon name. That all works. But, for users that ARE ALLOWED to save data, I want to show an update button. For those that are NOT ALLOWED, I don't want any button to show.

Is there a way to query a user's permissions for a given update without trying to perform the update?

1

There are 1 best solutions below

0
On BEST ANSWER

Have a look at the static method Global::hasTableAccess(tableId, AccessType)

So a call like

hasTableAccess(tablenum(SalesLine), AccessType::Edit)  

would check whether the user has sufficient rights to edit that table - in this case SalesLine

Via CallStaticClassMethod you can call it directly passing both arguments or write a simple thin wrapper in X++ with a new class which just accepts the table name and calls this method with proper values on your behalf - the latter having the benefit of not exposing the raw numeric table ID and enumeration value which may change in a future version.