make fields not editable if line type = Item
Giancarlo
Member Posts: 11
how can I accomplish the following.
in the Sales Order Subform
If Line Type = Item, Then 'Unit Price' and 'Unit Cost' fields editable property = No
My goal is to block people from changing the Unit Price and Unit Cost on the Items Sales Lines.
Each customer already receives a specific price as per their pricing Group.
However, I need to allow the user to enter a 'Unit Price' and 'Unit Cost' when the Sales line is a GL or Item Charge type.
How can I do this? do I need to code this on the form? or on the 'Unit Price' and 'Unit Cost' fields of the 'Sales Line Table'?
Any tips in the right direction are appreciated. Thanks in advance
in the Sales Order Subform
If Line Type = Item, Then 'Unit Price' and 'Unit Cost' fields editable property = No
My goal is to block people from changing the Unit Price and Unit Cost on the Items Sales Lines.
Each customer already receives a specific price as per their pricing Group.
However, I need to allow the user to enter a 'Unit Price' and 'Unit Cost' when the Sales line is a GL or Item Charge type.
How can I do this? do I need to code this on the form? or on the 'Unit Price' and 'Unit Cost' fields of the 'Sales Line Table'?
Any tips in the right direction are appreciated. Thanks in advance
0
Comments
-
Do code at form
No. - OnAfterValidate()
CurrForm.SAVERECORD;
and then;
Unit Price - OnFormat(VAR Text : Text[1024];)
IF Type= Type::Item THEN
CurrForm."Unit Price".EDITABLE(FALSE);
Guess it might works.0 -
Actually, I'd like to take this a step further and have you really think about what you are doing. Personally I think putting validation code on any form is wrong, and this one might be one of those cases.
We're talking about making a field editable, which is a display property, so on the surface that would be programmed on the form. The requirement behind it though is open for interpretation though. If the requirement in your company is that under no circumstances should the unit price and cost ever be editable, then it is more than just a form display property. If this is required behavior throughout the system, then you need to consider that this should really be programmed as field validation on the table level.
If it is just for this one form, the sales order subform, then putting the code on the form could be sufficient. However, the Sales Line table is displayed on a whole bunch of forms (sales quote, sales invoice, sales credit memo, blanket orders, returns), and if you need this behavior on all of those, now you are looking at making the same change to all of those forms. Now imagine this requirement changing in the future, you would need to modify the same thing on all of those forms again. Imagine somewhere down the line there is a need for a new form for the Sales Line table, and the person developing that form doesn't know about this requirement, you will have a form on which you can change those fields anyway.
When field validation is on a table level (which is where it belongs in my opinion), it is taken care of throughout the system, regardless of which form the table is displayed on. Of course you'd have to think about something that's not a display property, and perhaps raise an error instead, but there are ways to determine whether the field is being changed on a form (look up CurrfieldNo).0 -
If you decide to put the code on the form, then the code in Xin's post is definitely wrong. You should be looking at the OnAfterGetCurrentRecord trigger, and make sure that you take care of EDITABLE for all Type values.0
-
We did something like this in the past.
We have added a boolean on the sales line that is filled based on the sales header..to determine if an order is an "internet order" or "regular order"
we didn't want the "unit price" editable on regular orders so we added..
OnAfterGetCurrentRecord()
CurrForm."Unit Price".EDITABLE("Internet Order");
which worked fine.
But if you drop in a second "Unit price" field onto the sales line that one stays editable regardless.
Probably based on the FieldID is what I came up with. :-k
But since you can do that it wasn't very useful and we got rid of it.0 -
[Topic moved from 'NAV Tips & Tricks' forum to 'NAV/Navision Classic Client' forum]Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
I'll encourage the same thing I always do.Giancarlo wrote:If Line Type = Item, Then 'Unit Price' and 'Unit Cost' fields editable property = No
Imagine you're a user. You can change the price and cost on other lines, but you can't on this. Why? Unless the user has been trained on it, and remembers that training, they have no idea. To them, something is wrong with the system.
A TESTFIELD command, or better yet another error message, that explicitly tells them what they are doing wrong and why they cannot do it, works much better in my opinion.0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K 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
- 323 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

