Hi All,
I have a request to have one page that displays fields based on users' opened company.
Page ID 30 - Item Card
field number: 50000 - ABC -> has to be displayed for user that is logged into the Company A, while user that is logged into the company B must not see that field.
So far, I have managed to write the code to check for current opened company of user, but I am stucked on displaying fields based on users' currently opened (logged) company.
CU1 - Application Management
local procedure=isCountryB
On the Page ID 30 - Item Card
Global Variable=AppMgt | Codeunit | Application Management
CODE:
OnOpenPage
IF AppMgt.IsCountryB THEN
ABC :=TRUE; -> this does not work as expected, field is displayed anyway to any user that opens any company
Do you have any idea on best possible solution? I once created a copy of the page on company (original company) and then added it into the menu of company (B - additional company) for which this page is intended to be used, so that user would open that page under the (B - additional) company only, and if same user would open different (original) company, then it would have only an original page.
Thanks, Damjan
Hi,
I sorted this out with combination of Lars suggestion and my own.
Code:
Page ID 30
OnInit trigger
IF AppMgt.IsCountryB THEN
MyIsVisible := TRUE;
This checks currently opened company of user and displays field based on condition of boolean MyIsVisble and that is added on property: Visible of field on Page ID 30.
This AppMgt.IsCountryB will now be also used to apply the code as local specific of the country. (If country USA do this, else do that).
On T72 - Company information new field is added - Country as an option data type where all countries are inserted that represents country where company is registered.
I will not write core code that applies to all countries (companies) and local specific code that will be applied only to the users' currently opened company.
Thanks, Damjan
Hi Lars,
this is one possible solution, not bad either.
I just don't like that company is hardcoded.
Thanks, Damjan
Hi Duilio,
I have to create "hardcoded company" because I will need to write code to be valid only for company B, or C, or A, not not for all companies inside the database.
I do not know of any other solution, then that one.
And since I will have to do this, I wanted to use also this to display or hide fields based on currently opened company of the user.
If visibility management codeunit is something that would ease my work and ease the support I would be glad to use it, but I do not know it. I have always used so called "hardcoded company" as you are referring it.
Thanks, Damjan
Hi,
I guess you have thought of just using the system variable COMPANYNAME? So on the page set propery Visible to MyIsVisible, which is a new Boolean Variable, and then set it on Init of the page:
OnInit()
MyIsVisible := COMPANYNAME = 'ABC';
Hardcoding the company is something I dislike (brrr).
Given these constraint and if you do not want to spend time in considering to create a visibility management codeunit, I guess that you could create different groups in the card page and in each group you add the fields that you want to display per company.
Then you use the same boolean value to trigger visible true/false in these groups.
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,240 Super User 2024 Season 2
Martin Dráb 230,149 Most Valuable Professional
nmaenpaa 101,156