Security - Field based

I want to put security onto the Credit Limit field on the Customer Table. Does any one know a simple way of achieving this?

I believe there is no simple way. You have to program it. There is an add-on for field security. Both solutions are discussed in the following thread:

You don’t have to buy an add-on just for putting security on one field. Just remember that if you use this more and more often, you may have to consider it though. Here’s what I do: - Add a boolean field to the User Setup table, say call it ‘Allow Credit Limit Change’ - then in OnValidate of the credit check field, you do something like this: UserSetup.GET(USERID); IF NOT UserSetup."Allow Credit Limit Change" THEN ERROR('you are not allowed to change the credit limit'); UserSetup is a global record variable of subtype User Setup. Every time that a user changes the credit limit field, the system checks the user setup if the current user is allowed to do that. Of course, that user should not have permission to make changes to the User Setup table :slight_smile: hth

You could also create a role “ALLOWCREDCHANGE” and add some users to the role. If NOT(member of role) then …

I know you said Table level but I find a nice way to do this is to stop them changing it on the form by making the field uneditable. This way the users knows straight away they cannot edit it rather than trying then getting a error message. To do this you add code to then OnOpenForm of the customer card. You could add it to the onAfterGetRecord, but if the user is not allowed to change the Credit Limit no matter what I cannot see any advantage in it. Globals MemberOf Record Member of OnOpenForm Clear(memberof); memberof.setrange(“User Id”,USERID); Memberof.setrange(“Role Id”,‘ALLOWCREDITCHANGE’); If Memberof.find(’-’) then Currform.“Credit Limit”.Editable(True) else CurrForm.“Credit Limit”.Editable(false); OR you could do Clear(memberof); memberof.setrange(“User Id”,USERID); Memberof.setrange(“Role Id”,‘ALLOWCREDITCHANGE’); CurrForm.“Credit Limit”.editable(Memberof.find(’-’)); But I think the first one reads better, its easier to understand. Then as Ajhvdb said create a new role, ‘ALLOWCREDITCHANGE’. Add this role to the users that you want to allow to modify the credit limit. Hope this helps. Tony

Maybe simple, but aren’t the simplest solutions often the best [:D]? I would copy the form to a new form and make the field not editable. I did this for many standard Navision forms, because you will certainly have more customizations to a form than only this one. Besides, this procedure doesn’t affect standard forms, important when upgrading, isn’t it?. Attach the user to a (custom) menu with the new form(s) and there you go.


Originally posted by MFH “I would copy the form to a new form and make the field not editable.”

Would you not then need to point diffrent menus to different forms and increase the development that you have done? You would need a new menu for these users which would also need to be a copy of the original just pointing to your copied Customer Card form instead of the original. You then end up using more objects than you need to. If you placed the code I suggested into then OnOpenForm trigger then when upgrading all you need to do is copy the whole chunk of code (Or add in any new code). If you had two customer cards you would need to upgrade both copies.

Tony, I actually do have a customized menu for some departments, in order to have them only ‘bothered’ by the menu-options they need. So from this starting point, for me it’s not much effort to copy some (not all!) forms and attach these to the new menus. But, of course you’re right if it would only be for some small changes to a form. But since I’m not a developer, but only a humble end user [^] I mostly take the drag-and-drop procedures [;)].

As always, there are many solutions to one problem!

I don’t like using multiple Forms as it doesn’t feel safe. If the User is using the modified Customer Card Form (uneditable Credit Limit), goes into the Lookup Form (Customer List) and then clicks Customer->Card, she/he will be taken to the standard Customer Card where the Credit Limit Field is still editable. And there is not much you can do about it unless you start to place code all over the place. The other point is that most of Navision’s logic is based on the fact that the data is only checked at the time it is used, not at the time it is filled in. There can be a lot of error messages when trying to post an Entry although there were none when filling the data in. Let the User get the error message when he tries assigning a value to some field he can’t use. It will work just like standard permissions thus contributing for a common user interaction experience. [edit] corrected a typo

Thankyou all. I think that the simple code that ‘DenSter’ Suggested should work. Currently, due to my predecessor, We have over 100 non standard forms, effectively two per Licenced user. I’m not sure if you can imagine what a nightmare this is. As ‘nelson’ mentioned, Navision is fully intergrated and Navigatable, therefore this crazy Menu Level Security is going to go, and I advise anyone who is considering creating menus all over the place, Don’t, You’ll regret it, or at least t your users will. Regards John