Setting table field's property EDITABLE in code
Archy
Member Posts: 70
Hi all!
Is it possible, to set field property EDITABLE (or VISIBLE or ENABLED) in code of table? when i tried to write: field1.EDITABLE := FALSE i received following error message: "The variable is not a record. 'Variable.Field' is invalid". But field1 is not a variable, it is a field in a table!
Thanks!
Is it possible, to set field property EDITABLE (or VISIBLE or ENABLED) in code of table? when i tried to write: field1.EDITABLE := FALSE i received following error message: "The variable is not a record. 'Variable.Field' is invalid". But field1 is not a variable, it is a field in a table!
Thanks!
0
Comments
-
You can set a field editable runtime on a form.
Currform.Control.Editable(Boolean)
0 -
Mark Brummel wrote:You can set a field editable runtime on a form.
Currform.Control.Editable(Boolean)
But in this case field doesn't update till I go to another record and go back.
currform.update didn't help.. Any other ideas? :-s 0 -
-
-
It is a table form and i need it to update if user has entered value in another field - it can be when new record is entered or existing record is updating. if Field2 <> '' then Field1.enabled := true ELSE Field1.enabled := false. But the form doesn't refresh controls.
0 -
Have you tried the OnAfterValidate trigger of the control that determines the visibility?0
-
It is not good to work with Editable and Enabled properties on table form. (Whole column is disabled etc.). Try to do it in another way - for example when entering value into the "disabled" column, test the condition and show error that user must firstly fill another field...0
-
Yes, that's the Nav way. Test the value instead of enabling controls.0
-
We have such condition:
if Field1 <> '' then
Field2.ENABLED := FALSE
else
Field2.ENABLED := FALSE;
In trigger OnAfterValidate for Field1 I added such code:
IF Field1 <> '' THEN BEGIN
CurrForm.Field2.EDITABLE := TRUE;
CurrForm.UPDATECONTROLS;
END ELSE BEGIN
CurrForm.Field2.EDITABLE := FALSE;
CurrForm.UPDATECONTROLS;
END;
But it doesn't work!
0 -
Oh, I have told wrong, it's not table form, it's card form.. :oops:0
-
UPDATECONTROLS is for the captionclass.
You can tryCurrForm.Field2.EDITABLE(Field1 <> '' );
in the OnAfterValidate trigger of the Field1 control.
It should work without an update0 -
It doesn't work!
0 -
What is the value of the Editable property in the table? If you want to change it at form-level it should be editable in the table.
It should also be in the OnAftergetCurrRecord trigger. (the code that is)
Best is to make a function like in the customer card.0 -
Mark Brummel wrote:What is the value of the Editable property in the table? If you want to change it at form-level it should be editable in the table.
It should also be in the OnAftergetCurrRecord trigger. (the code that is)
Best is to make a function like in the customer card.
In table editable is TRUE...
Actually, I would like to find example and take solution from it, but I can't find it. I didn't find in Customer Card such a thing..
It seems, in Customer Card controls Editable properties aren't changed at runtime.. Am I wrong? 0 -
This is true.
But you can make a test in a cronus database with the customer card.
Open it, click on the Name field.
In the OnAfterValidate trigger put this codeCURRFORM.Address.EDITABLE(Name = 'Mark');
This shoud work.0 -
When I delete the value from Field1, Field2 became uneditable, as I wish. But, when enter value into Field1, Field2 doesn't became Editable before leave this record and arrive on it. In first situation Form's OnAfterGetRecord trigger runs, when I enter value it doesn't run. I can't understand, why so.
Please, help! 0 -
When you change the value the OnAfterValidate triggers is run, so your code needs to be in 2 places!
Thats why a function is the best solution.0 -
May be someone can tell, what may call table's OnAfterGetRecord trigger in cases when we didn't leave current record?
May be LOCKTABLE can cause this? Or function calls? Or, maybe, codeunit calls? 0 -
I think the working of the form triggers is not clear to you.
To see what triggers are used you can put messages into the trigger and try what triggers are used when browsing through record and changing values.
LOCKTABLE or codeunits are definately not calling form triggers.0 -
](*,)
But thanks anyway!
0 -
Oh, i found! When deleting value from this field - triggers OnValidate, OnAfterGetRecord and OnAfterValidate are running. When enter new value, the NO trigger runs!0
-
I'm trying something similar but I can't seem to get it to work
Every Sales Header has a boolean "Internet order"
If the "Internet order" = True then I want the "Unit Price" field on the Sales Line to be editable.OnBeforeInput<> IF SalesHeader."Internet Order" THEN CurrForm."Unit Price".UPDATEEDITABLE(TRUE);
But I doesn't seem to work. It's always UNEDITABLE with this code.
Am I using the wrong trigger?
Also triedCurrForm."Unit Price".EDITABLE(SalesHeader."Internet Order" = TRUE);
0 -
Is the internet order a static field? Then you'll only need to change the onaftergetcurrrecord trigger or the FORM with
CurrForm."Unit Price".EDITABLE("Internet Order");
If the Internet Order field is also an editable field you'll also need to change the OnAfterValidate trigger if the FIELD with the same code.
Good luck!
If nesesairy I'm willing to make a small example and mail it to you. 8)0 -
We import our Internet orders via a dataport.
The imported orders set the "Internet Order" Checkbox to YES on the sales header
The Internet Order Checkbox is on the sales header.
We do not want the prices to be changed for any regular order but sometimes we need to adjust the price on the internet orders.
So the internet order flag is on the sales header and we want to lockdown the sales line "Unit Price" if it's not an internet order
My Current Code isOnAfterGetCurrRecord() CurrForm."Unit Price".EDITABLE(SalesHeader."Internet Order");
But the Unit Price Is uneditable if it's an internet order or not.
Does this work differently because it's a subform?
note:The Internet Order boolean is not editable.0 -
Update - So I added the "Internet Order" Boolean to the sales line also and the code works fine. It was when trying to pull the value of the boolean from the sales header that didn't work.0
-
-
yes i got it to work but anyone have a specific reason why it wouldn't work if asking the code to look at the header and give me what i needed?0
-
When (where) you are getting the value into SalesHeader variable?0
-
I have a table form, in which I have created a global Option and a boolean.
Depending on if the boolean is true or not, the textbox displaying the Option should be Enabled or disabled.
As far as i know the CurrForm only displays items in the table attached to the form.
Do you have any suggestions to how I can access the control on the table ?
0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.7K Microsoft Dynamics NAV
- 18.8K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 328 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions

