Somebody asked me if I would be able to make a functionality in Navision to hide any control in a Form.
For example, I want to hide some controls in Customer table for some users.
If the user "Mike" opens the Customer form he would not be able to see the Customer's Name.
But I don't want to write it like this:
If USERID := "Mike" Then
Currform.Controls.Name.VISIBLE := FALSE;
I want to be able to read from another table which field user "Mike" allowed to see, and write this kind of code in the Form:
"User Field Access".SETRANGE("User ID",USERID);
If "User Field Access".FINDSET Then
REPEAT
Currform.Controls.("User Field Access".FieldName).VISIBLE := "User Field Access".Visible;
UNTIL "User Field Access".NEXT = 0;
I really don't expect Navision to handle this kind of code but I have to ask you...and hope it can. :whistle:
Comments
Eric Wauters
MVP - Microsoft Dynamics NAV
My blog
Same for me... :-)
You cannot access the controls dynamically without using some external automation...
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
Indeed there is no collection or table in NAV which hold the list of all control on the form.
But if you think a bit longer it is not so painful. Or - even if it was such a collection it would be not easy, (if not possible at all) to create a fully user-configurable solution, simple because all the controls have their own names, not necessarily following the names of variables or fields. So in virtually almost any case some small developer intervention would be required.
I've did some similar functionality, configurable to some extent. It allowed to hide some field or make the whole form or only single field readonly for some users or some database roles.
The key was to write come small piece of code which could be copied from one form to another and easily modified on the form. Of course more field you need to control the more code you would need, but - on the other hand- do you really need to control all, or most of the controls on all of the forms ? I would say no - you would rather need to control some small number of fields on some forms, which are really important from business or application point of view.
Regards,
Slawek
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03
You mean like the "Field Level Security" add on from Lanham thats been around for many years now.
ERP Consultant (not just Navision) & Navision challenger
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
Eric Wauters
MVP - Microsoft Dynamics NAV
My blog
I don't know Lanham, but probably yes.. My solution purpose was to achieve field level security and visibility People (including me) all the time are reinventing the wheels
Regards,
Slawek
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03
Eric Wauters
MVP - Microsoft Dynamics NAV
My blog
Eric Wauters
MVP - Microsoft Dynamics NAV
My blog
Almost identical concept, indeed
Mine didn't apply filters on data so restricting range of accounts for user was not possible.. But mine allowed to configure visibility for single Users, Database Roles, Windows Groups, included 'default permissions' and allowed to 'allow' or 'deny' view or edit privileges.
Regards,
Slawek
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03
If you're running on Navision 5.0 you could build a very similar custom form to the original card (say the customer card) that is based on a temporary recordset. Then if you built a control function that handled the displaying of each record you could clear the value through some generic code that runs in the OnAftergetRecord.
If you further need to restrict edits to the table you could handle that in the table directly and have some code that throws an error in the OnModify trigger of the customer table.
Alternatively to all this you could build a seperate form for these users that need a restricted data set and then use permissions and custom menus to control what they access.
I don't think I would hold out much hope that MS will provide access these types for form/display objects in the near future. NAV2009 seems to be based on some similar structures and does not provide a better development environment. Mabye NAV 7.0?
Epimatic Corp.
http://www.epimatic.com
Which part of "There Is An Add-On Available From Lanham To Do This" was I not clear enough about?
But there's nothing wrong if they want to try & develop something on their own. who knows maybe they could come up with a neat new add-on.
Epimatic Corp.
http://www.epimatic.com
Ah OK, competition is always a good thing. I thought from your post that you felt there was NO solution available. But you are saying that you want to make a better one.
Like in .Net there is a control collection for a form that you can loop through to access text boxes, labels, etc. Which is what the original post was hoping to find a way of doing.
I don't think the new Page or Form object in Nav2009 expose this kind of functionality.
Epimatic Corp.
http://www.epimatic.com
Regards,
Slawek
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03
[-X
Better to foresee some setup-fields instead.
Eric Wauters
MVP - Microsoft Dynamics NAV
My blog
His code is not that bad at all, by using a role and not a userid is almost the same as using a setup field. If he documented this it's ok by me. My 2 cents.
Just a few simple examples:
What happens if somebody create another company in the same database, and create another role called DIRECTOR but for different purposes for example....
What if anybody needs to hide the same fields but for different role name in the same or different company.
What if anybody (company NAV admin not involved in development at all) rename roles.
What if company wants to change structure and adjust roles accordingly.
And probably a few more..
Regards,
Slawek
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03
My personal opinion is that this is very bad practice, and its dangerous that someone sees this code and since its on mibuso accpets it as gospel. Not only do we prevent future readers from making the same mistake, we also help the original poster to correct is practices and be a better programmer going forward.
What will be the good practice? :-k
So you document to the user that if they want this functionality, they should name the role "DIRECTOR" (exactly that, and nothing else)... and warn them ... if they use "DIRECTOR", this functionality is triggered... .
Hm :-k no, not for me, thanks ... my two cents.
Eric Wauters
MVP - Microsoft Dynamics NAV
My blog