How to validate quantity from another field ?

haihth
Member Posts: 32
Hi all,
I'm trying to insert a new line into sales line with code below
Everything is OK except the quantity of item AAA is not checked with inventory.
When i input quantity of AAA by manual, the system warning "Check Availability". But when i using code like above, the system not check inventory of item AAA.
How can I call validate quantity from another field.
Thanks for helping me.
I'm trying to insert a new line into sales line with code below
No. - OnAfterValidate() SL.RESET; SL."Line No.":=GetLastLineNo(Rec."Document No.")+10000; SL."Document Type":="Document Type"; SL."Document No.":=Rec."Document No."; SL.Type:=Rec.Type; SL."No.":='AAA'; SL.VALIDATE("No."); SL.Quantity:=1000; SL.VALIDATE(Quantity); SL.INSERT; CurrForm.UPDATE;
Everything is OK except the quantity of item AAA is not checked with inventory.
When i input quantity of AAA by manual, the system warning "Check Availability". But when i using code like above, the system not check inventory of item AAA.
How can I call validate quantity from another field.
Thanks for helping me.
0
Comments
-
Have you run the code using the debugger to see if it did execute (and how) the CheckItemAvailable function?0
-
<snip>
SL."No.":='AAA'; SL.VALIDATE("No."); SL.Quantity:=1000; SL.VALIDATE(Quantity);
OK so in general, just a few things:
1 - DO NOT give your variables these weird names. If you have a record variable into the Sales Line table, then call it SalesLine. It makes the code easier to read, less effort to troubleshoot, and all around better for everyone.
2 - you can directly assign a value while using VALIDATE, like this:SalesLine.VALIDATE("No.",'AAA'); SalesLine.VALIDATE(Quantity,1000);
0 -
lvanvugt wrote:Have you run the code using the debugger to see if it did execute (and how) the CheckItemAvailable function?
I've checked the funtion CheckItemAvaible in Sales Line table. It'll run with current field no. But i can not call this function from form trigger "No." OnAfterValidate.
When I call
SL.CheckItemAvailable(FIELDNO("No."));
The system warning . ( SL is record Sales Line )
"You have specified an unknown variable. CheckItemAvailable"
How can i call this function from trigger OnAfterValidate of "No." field0 -
You're doing this from form level, not table?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
- 320 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