Visible - editable

I want to ask; is there any way to control the fields on a form (visible, editable) from a codeunite?

Not directly. From a codeunit you do not have access to any control variables on a form.

However, you can create mimic this functionality.

Create a table with fields that represent the state you want a given control to appear in.

In a single instance codeunit, have a reference to a temporary record of this table.

In your codeunit, set the values of the temporary record.

In the form, set the value of the controls by accessing teh temporary record in teh single instance codeunit.

Create a function on the form to manage hiding the fields e.g. HideFields. Use code within the function to hide the fields that you want to hide:

CurrForm.<Control Name>.VISIBLE(FALSE);

for example:


Then from your codeunit create a Form variable to run your form and reference the form’s function:


You can only run that sort of code from a form. They would like this functionality when run from a codeunit.

I tested this in a NAV 5 client before posting. Did it not work for you?

Even if you start a Form from a codeunit these lines of code will work.

Ah, I didn’t read the last line of your original post.

I stand corrected; that does work.