Dear friends,
I am creating a page with around 400 fields, and 300 fields of them should change the visibility and caption dynamically according to the user setup record from set up table.
My requirement is to set the visibility and caption of 300 fields in code C/AL dynamically. As far as I know, I can set a boolean variable as visible property for fields. But what about caption? Also, as I have so much fields, can I simplified the process by some code like below
_FieldControl.visible(false);
_FieldControl.caption('ABC');
Thanks in advance.
*This post is locked for comments
Hi Andre
How can you split the balance by transaction currency on a main account in Management Reporter
OK, then l am thinking whether it is possible to assign the variable value by a way like this?
Declare my boolean variable as C_1Visible;
Text 60: ItemName:='C_1';
SetVariableValueByName(ItemName+'Visible', TRUE); //Set the variable value by the variable name
In this way I can use loop to assign the variable value... Thanks!
For visibility, you need to set the Visible property of your fields to a boolean variable (for example IsField1Visible and so on). Then, setting this variable to true of false in code does what you want to obtain (field visible or not accordingly to the variable's value).
You cannot loop through controls in a page, so this is the unique way.
Thanks Stefano, following your suggestion the caption problem is solved by set the field Captionclass property to sth like '1,5,,' + GetItemName(C_1).
But unfortunately, when I try to do the same thing for field property visible(set as a boolean function GetItemVisibility(C_1)), a error will pop to said "unknown function type". So does it mean I can only use variable rather than function to dynamically set the visible property?
As I have multiple fields, it is not possible to set the variable value one by one like below
If C_1Rec.Display=true then
C_1Visible:=true;
Else if C_2Rec.Display=true then
C_2Visible:=true;
I would like to use function to dynamically return boolean value or do you have any other advise? Thanks a lot!
CAPTIONCLASS or this event is the way you have in NAV.
Check here, maybe it could be helpful:
gaspodethewonderdog.blogspot.it/.../field-captions-and-captionclass.html
400 fields, a lot of records and such trigger will slow down the page viewing time a lot.
If users will make some filters too (and if there are many ... users I mean) I don't see this solution too responsive.
The event described is triggered when the page renders the field caption, so here you can place the code you want to change the caption. For example, you can check the field ID and change the caption accordingly (I don't know your requirements for this logic). So, if your page has 1000 fields, you can check the field ID and change is caption accordingly.
Can you group those users in some roles?
Maybe it is eraser to make a page for every role and give permission for it only for that role.
Hi Stefano, I think you may misunderstand my problem. My problem is not how to trigger the caption and visible property change, but is how to change them by code.
Actually I have two question,
1. How to change visible and caption property by C/AL code, do sth like below ?
_FieldControl.visible(false);
_FieldControl.caption('ABC');
2. As I have hundreds of field need to do so, can I have an efficient loop to achieve my requirement?
Thanks a lot.
Thanks Stefano, and do you have any idea about visible property for hundreds of fields?
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,151 Super User 2024 Season 2
Martin Dráb 229,993 Most Valuable Professional
nmaenpaa 101,156