not editable subform is automatically disabled
Minu63
Member Posts: 16
To prevent some important data from unwanted modifications, we integrated a so-called "Modification Button" in several forms, so as in form 42 "Sales Order". There is following code behind this button:
CurrForm.EDITABLE(NOT CurrForm.EDITABLE);
CurrForm.SalesLines.FORM.SetFormEditable(CurrForm.EDITABLE);
In the subform 46 "Sales Order Subform" the new function "SetFormEditable" looks as follows:
CurrForm.EDITABLE(_Editable);
CurrForm.UPDATE;
This works more or less fine, but has one big problem: If there aren't any records to show in the subform, the subform is not only set to "not editable" but also automatically set to "not enabled"! And the status of the subform remains "not enabled" even if you change to status of the main form to "editable".
I attempted several combinations of CurrForm.ACTIVATE, CurrForm.ENABLE, etc. but the only workaround that ran was inserting an empty sales line, change the subform to "editable" and than deleting the just created sales line. Has anyone a better solution? Thanks in advance.
CurrForm.EDITABLE(NOT CurrForm.EDITABLE);
CurrForm.SalesLines.FORM.SetFormEditable(CurrForm.EDITABLE);
In the subform 46 "Sales Order Subform" the new function "SetFormEditable" looks as follows:
CurrForm.EDITABLE(_Editable);
CurrForm.UPDATE;
This works more or less fine, but has one big problem: If there aren't any records to show in the subform, the subform is not only set to "not editable" but also automatically set to "not enabled"! And the status of the subform remains "not enabled" even if you change to status of the main form to "editable".
I attempted several combinations of CurrForm.ACTIVATE, CurrForm.ENABLE, etc. but the only workaround that ran was inserting an empty sales line, change the subform to "editable" and than deleting the just created sales line. Has anyone a better solution? Thanks in advance.
0
Comments
-
0
-
I'm pretty sure you don't need the editable function on the subform at all. The editable property on the parent form should be inherited by the subform.
And, very unrelated, but you should technically be doing CurrForm.EDITABLE := YourValue instead of CurrForm.EDITABLE(YourValue). I know it's the same thing, but the first is the proper syntax.0 -
I'm sorry but you aren't right: you need the editable function on the subform if you want to avoid another inexplicable behavior of Navision: Although the editable property is inherited to the subform you still can delete records from the subform! Try it out...matttrax wrote:I'm pretty sure you don't need the editable function on the subform at all. The editable property on the parent form should be inherited by the subform.
I know that both syntaxes exist and that's the same but my one seems more "elegant" to me. I also prefer p.e. "IF boolean THEN ..." instead of "IF boolean = TRUE THEN ...".matttrax wrote:And, very unrelated, but you should technically be doing CurrForm.EDITABLE := YourValue instead of CurrForm.EDITABLE(YourValue). I know it's the same thing, but the first is the proper syntax.0 -
Minu63 wrote:To prevent some important data from unwanted modifications, we integrated a so-called "Modification Button" in several forms, so as in form 42 "Sales Order". There is following code behind this button:
CurrForm.EDITABLE(NOT CurrForm.EDITABLE);
CurrForm.SalesLines.FORM.SetFormEditable(CurrForm.EDITABLE);
In the subform 46 "Sales Order Subform" the new function "SetFormEditable" looks as follows:
CurrForm.EDITABLE(_Editable);
CurrForm.UPDATE;
This works more or less fine, but has one big problem: If there aren't any records to show in the subform, the subform is not only set to "not editable" but also automatically set to "not enabled"! And the status of the subform remains "not enabled" even if you change to status of the main form to "editable".
I attempted several combinations of CurrForm.ACTIVATE, CurrForm.ENABLE, etc. but the only workaround that ran was inserting an empty sales line, change the subform to "editable" and than deleting the just created sales line. Has anyone a better solution? Thanks in advance.
Personally I think this is a bug, but its been like that since the first release of Financials. I have reported this to PC&C (over 10 years ago) but never got a reply. Actually I reported a lot of bugs in SubForms, but most of them are still there.David Singleton0 -
-
Dear BeliasBelias wrote:
I tried it out but I think you have the same problem as I: if you filter p.e. the currency code to "XYZ" your buttons are disabled too and don't work any longer (with or without the codeunit).0 -
Minu63 wrote:I'm sorry but you aren't right: you need the editable function on the subform if you want to avoid another inexplicable behavior of Navision: Although the editable property is inherited to the subform you still can delete records from the subform! Try it out...
So it is correct, it's just that you have another problem with the way it works. I would agree that when it inherits the property you should not be able to delete records. I was about to suggestIF NOT CurrForm.EDITABLE THEN ERROR('You cannot delete records from an uneditable form')
in the OnDelete trigger of your subform. I tried it out and although the property is inherited CurrForm.EDITABLE still returns TRUE. I can see your frustration
What an annoying problem. I'm really surprised I've never run into it before.
A real hack of a solution here, but it should work. It's far from elegant and I would definitely put some text in the documentation trigger explaining it. Have the editable property inherit from the parent form. But also have your function that, instead of setting the EDITABLE property, sets a global variable. Use that global variable as a conditional in your OnDelete trigger like in the snippet above. You still get the confirmation of "Do you want to delete the record?", unfortunately, but it will prevent you from deleting it.0 -
i posted the link before the whole discussion of subform bug: it should have solved the issue about the empty table (which was one of the original problems)David Singleton wrote:Belias wrote:
What has that thread got to do with SubForms :-k0 -
Belias wrote:[
i posted the link before the whole discussion of subform bug: it should have solved the issue about the empty table (which was one of the original problems)
Gotcha.
David Singleton0
Categories
- All Categories
- 75 General
- 75 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
- 611 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 253 Dynamics CRM
- 103 Dynamics GP
- 6 Dynamics SL
- 1.5K Other
- 991 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 28 Design Patterns (General & Best Practices)
- Architectural Patterns
- 9 Design Patterns
- 4 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1K General Chat
- 1.6K Website
- 77 Testing
- 1.2K Download section
- 23 How Tos section
- 249 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions

