fields to be not editable

hi,

I have two dropdowns …

one is candidate status and other one is current status…in candidate status i have options like selected,application and in current status active and inactive.

if i select 'selected ’ the current status should be inactive similarly if a select application current status should be inactive.this is working fine

IF (“Candidate Status” IN[“Candidate Status”::Application,“Candidate Status”::Shortlisted,“Candidate Status”::Interview]) THEN
“Current Status”:=0;
IF (“Candidate Status” IN[“Candidate Status”::Selected,“Candidate Status”::Rejected]) THEN
“Current Status”:=1;

with this code,but now i required is if current status is inactive then all the fields should be non editable …only fields not the menubuttons…

i have tried this code where the full form was not editable

CurrForm.EDITABLE(FALSE);

can u please help me out…

this is the main feature i have to develop.

Hi Bavani,

First of all, if you only want a part of the controls to be non-editable, not the entire form, you have to give the controls a name. (in the property-sheet of the control)

Second you have to define a new function on the form, called something like UpdateEditable

This new function has to be called from both the OnAfterGetCurrentRecord-trigger, as well as the OnValidate-trigger of the control that holds the “Current Status”-field.

In the new function you put lines of code like this:

CurrForm.MyControl1.EDITABLE(“Current Status” = 1);
CurrForm.MyControl2.EDITABLE(“Current Status” = 1);

(Make the list of all the controls you want to change the Editable-property on)

hi,

I am not getting this what actually u mean

‘you have to give the controls a name. (in the property-sheet of the control).’…please tell me about this clearly…rest i have understood

i have many textboxes to be noneditable.so how to proceed…

more over if am giving this line

CurrForm.EDITABLE(FALSE);

I am not able to navigate a new record.

please help me out

In design-mode of the form. Focus on the control, and open the property-sheet. The 2. property from the top is Name. Give it a Name, and you’ll be able to find it in the C/AL-symbol menu (and thereby also change some of the properties on the control at runtime)

Hi Alexander,

Actually whenever the candidate is selected or rejected his status should become inactive and we should not able to edit any of his fields other than the first name.

if you dont mind can u please explain wat properties should be changed in C\AL symbol.

Since im new to NAvision not able to get you clearly.

thanks…

Hi Bavani,

[:$]
I just wanted to make a little example for you, and i realized that naming the controls is not needed.
You can still find them in the C/AL Symbol menu.
(Ok after 10 years of doing this i learned this rather basic thing… Fast learner [:D])

So to sum up things…

  1. You need to create the UpdateEditable-function in the form.
  2. You need to write code to this function, where you change the EDITABLE-property on the controls you want.
    This is done the way i descriped earlier, line by line for each control you want to change.
  3. You need to call this function from both the OnValidate-trigger of the “Current Status”-field/control and from OnAfterGetCurrentRecord-trigger of the form.
    Simply write:
    UpdateEditable();
  4. Last you need to change the code you already wrote that changes the “Current Status”-field.
    Instead of doing a simple assigning of the value, do a VALIDATE instead.
    This way the OnValidate-trigger is called, and thereby your new function.
    Write something like:
    VALIDATE(“Current Status”,“Current Status”::Active);
    Instead of:
    “Current Status” := 1;
    (I like to write the code so that the option-value is visible, not just the underlaying integer-value. Makes it easier to read the code afterwards i think)

Hope this makes sense.

btw…
Out of principle i think you should test if the field-value has changed at all, before you do anything in the OnValidate-trigger.
I always (almost) put a line like this in the beginning of the OnValidate-trigger:
IF ThisField <> xRec.ThisField THEN BEGIN

END;

What he is basically saying is you can’t just blanketly make a form uneditable. What if you make a mistake, you won’t be able to access the fields again.

There is a little trick to make a field EDITABLE on a NON-EDITABLE form which is to add this code to the field you want to still have access to.

OnActivate()
CurrForm.EDITABLE(TRUE);

OnDeactivate()
CurrForm.EDITABLE(FALSE);

When you’re on that field the form becomes editable again & when you leave it , it once again locks down.

Are you able to understand Alexander’s post and the steps you need to take?
If you can’t follow those directions then you probably need to study more carefully and play with code on test systems.