Which trigger to implement this?

mysamza
Member Posts: 66
I am trying to write code on Sales Order's subform;
Quantity Remaining = Quantity - Quantity Shipped - Reserved Quantity
Quantity Remaining is a new field I added by extending the Sales Line table and Sales Order Subform.
This value will be Quantity - Quantity Shipped - Reserved Quantity
However, Quantity Shipped only gets a value once the SO is shipped with the value in Qty to Ship.
I tried writing the following code on ExtendedSalesLineTable
The problem is, I get Not Available in Rec.Quantity Shipped hence it always show me new field Remaining Quantity as 0.
Quantity Remaining = Quantity - Quantity Shipped - Reserved Quantity
Quantity Remaining is a new field I added by extending the Sales Line table and Sales Order Subform.
This value will be Quantity - Quantity Shipped - Reserved Quantity
However, Quantity Shipped only gets a value once the SO is shipped with the value in Qty to Ship.
I tried writing the following code on ExtendedSalesLineTable
trigger OnModify() var begin IF rec."Quantity Shipped" <> 0 then begin recSalesLine.SetFilter("No.", Rec."No."); recSalesLine.SetRange("Line No.", Rec."Line No."); recSalesLine.SetFilter("Document No.", Rec."Document No."); if recSalesLine.FindFirst() then begin "Quantity Remaining" := (Rec.Quantity - Rec."Quantity Shipped") - rec."Reserved Quantity"; recSalesLine.Modify(); end; end; end;
The problem is, I get Not Available in Rec.Quantity Shipped hence it always show me new field Remaining Quantity as 0.
0
Answers
-
You are using recSalesLine and then modify without making any change on that record?
Also why don't you use for example a codeunit with eventsubscriber when table sales line is modified?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