O'Reilly logo

Microsoft Dynamics NAV 2009 Programming Cookbook by Matt Traxinger

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Checking for user-assigned roles

The NAV system checks permissions every time you look at data or run an object, but what if you need to check permissions manually? This recipe will show you how to examine a user ID to check for a specific role.

How to do it...

  1. Create a new codeunit from Object Designer.
  2. Add a global function called VerifySecurity that returns a Boolean value named HasPermission.
  3. This function should take in three parameters:

    Name

    Type

    Length

    RoleID

    Code

    20

    CompanyRequired

    Boolean

     

    SuperAllowed

    Boolean

     
  4. Add the following code to the function:
    HasPermission := CheckUserId(RoleID, CompanyRequired, SuperAllowed);
    
  5. Add a global function called CheckUserID that returns a Boolean value.
  6. This function should take in the same three ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required