Read object permissions

jorgitojorgito Member Posts: 115
Hi all.

Is there a function that can return if the user has permission on an object, other than a record (e.g form, report, codeunit)?

For example, to find out if a user has permission on a table, you would use READPERMISSION. Is there a similar way for the other objects (forms, reports codeunits)?

We have created a report that is a substitute to one of the standard reports. Some customers have access to this report and some others don't (because of the license each one has). We have a button on the Customer Card and we want to check if the user (through the license) has access to this object. If he has, show our report, otherwise, show the standard report. Right now, if the user does not have permissions, Navision displays the message "You do not have permission..." and displays nothing.

What can we do ?

Thank you in advance
Jorgito

Comments

  • garakgarak Member Posts: 3,263
    There is no System function. but take a look to the Table "License Permission"
    Do you make it right, it works too!
  • jorgitojorgito Member Posts: 115
    You are right!

    I can search in the License Permission table to find if the license has permission on an object.
    IF Permissions.GET(Permissions."Object Type"::Report, 51000) THEN BEGIN
      IF Permissions."Execute Permission" = Permissions."Execute Permission"::Yes THEN 
        // Run our report
      ELSE
        // Run the standard report
    END ELSE
      // Run the standard report
    

    Thanks a lot
  • garakgarak Member Posts: 3,263
    You're welcome
    Do you make it right, it works too!
  • kinekine Member Posts: 12,562
    There is still one question: if the process request to run report A, but you will run report B because user have no permissions to report A, for me it could lead to inconsistent system. Better is to throw out the error and solve the case (assign missing rights to the user or change process). There will be only small count of cases when you will need to run different process based on permissions (I hope that this is one of them)... Do not implement this blindly, it could be hidden problem... :whistle:
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
Sign In or Register to comment.