mibuso.com

Microsoft Business Solutions online community
It is currently Wed Jun 19, 2013 11:45 pm

All times are UTC + 1 hour [ DST ]




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Secure one field on a form using the "User Role"-table
PostPosted: Mon Nov 16, 2009 10:50 am 
Offline
Moderator
MVP Microsoft Dynamics NAV
NAV TechDays 2013 attendee

Joined: Wed Jul 02, 2003 10:13 am
Posts: 7526
Location: Milan
Country: Italy (it)
If you need to secure 1 field on a form, you can do that in different ways:

I give an overview of the different ways (and also add an extra way that I think is the best of all).
1) hardcode each user in the form
+: fast to program the first time
-:each time something in security changes, you need to reprogram

2) use standard security and 2 different forms with some setup
-: you need to maintain 2 forms
+:each time something in security changes, you just change the form for that user in the setup.

3) use a standard role and have some custom code in the form
+: fast to program, because you just create some code in the OnOpenForm
+: only 1 form to maintain
-:each time something in security changes, you just add (or remove) the role from the user

How to do it?
-Create a role in table "User Role". You do NOT need to add permissions to it.

-Create a new field in some setup table (Company setup, G/L Setup, Inventory Setup, Some new setup table, ....). Be sure you use the best setup table to make it easier to find it again (Just don't put a field that must secure something about inventory in the Fixed asset setup).

-In the OnOpenForm-trigger of the form, put this code:
Code: Select all
recSomeSetupTable.GET();
CurrForm."The Field".VISIBLE(UserHasRoleInCompany(USERID,recSomeSetupTable."The New Role ID",COMPANYNAME,FALSE,TRUE));


-To add a user that can see that field:
Go into Tools=>Security=>Database/Windows logins=>Add the new role to his login.

Oh. For the definition of function "UserHasRoleInCompany": see here: http://www.mibuso.com/forum/viewtopic.php?t=10695

_________________
Regards,Alain Krikilion
Use the SEARCH,Luke! || No PM,please use the forum. || May the <SOLVED>-attribute be in your title! || Read Forum Rules before making a posting


Top
 Profile  
 
 Post subject: Re: Secure one field on a form using the "User Role"-table
PostPosted: Mon Nov 30, 2009 12:44 pm 
Offline

Joined: Tue Apr 11, 2006 10:00 pm
Posts: 1188
Location: Vienna
Country: Austria (at)
Another possibility is adding a checkmark to the User Setup table.

_________________
Sorry, no support using PM, e-mail or MSN - please use this forum.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum


Search for:
Jump to: