Updating other fields based on changes in a flow field

blh
Member Posts: 24
This is sort of a long explanation so bear with me! One department in my company has an excel spreadsheet from which we import costs and other information into a table in NAV through an XML port. The table in NAV is called the Replacement Cost table. In another table called the Customer Pricing table we have a flow field called Replacement Cost which looks up the Replacement Cost from the Replacement Cost table. By choosing various criteria like shipping location, item etc. the Replacement Cost flow field in the Customer Pricing table will change. For instance in the On Validate trigger in the item field I have the following code to recalculate the Replacement Cost field: “CALCFIELDS("Replacement Cost");”.There is another field in the Customer Pricing table called Unit Price which calculates the unit price of an item based on the value in the Replacement Cost flow field and a couple of other fields. What I want is for the Unit Price to be updated every time the value in the Replacement Cost flow field has changed. I have code to calculate the Unit Price in the On Validate trigger in the Replacement Cost flow field in the Customer Pricing. It reads as follows:
IF "Margin Type" = 0 THEN BEGIN
"Unit Price" := "Replacement Cost" + Margin + "Rebate Amount"
END
ELSE
"Unit Price" := "Replacement Cost" + ("Replacement Cost" * (Margin/100)) + "Rebate Amount";
The Unit Price is not updating when the Replacement Cost value changes. The Unit Price field is not updating when someone changes the value of one of the fields that changes the Replacement Cost value. For instance when somebody changes the item field the Replacement Cost changes and thus, in my thinking at least, the unit price should be recalculated. Where have I gone wrong? Also how can I ensure that whenever a new replacement cost is imported into the Replacement Cost table that the Unit Price is updated in the Customer Pricing table based on the new cost? Thanks for any help that can be provided.
IF "Margin Type" = 0 THEN BEGIN
"Unit Price" := "Replacement Cost" + Margin + "Rebate Amount"
END
ELSE
"Unit Price" := "Replacement Cost" + ("Replacement Cost" * (Margin/100)) + "Rebate Amount";
The Unit Price is not updating when the Replacement Cost value changes. The Unit Price field is not updating when someone changes the value of one of the fields that changes the Replacement Cost value. For instance when somebody changes the item field the Replacement Cost changes and thus, in my thinking at least, the unit price should be recalculated. Where have I gone wrong? Also how can I ensure that whenever a new replacement cost is imported into the Replacement Cost table that the Unit Price is updated in the Customer Pricing table based on the new cost? Thanks for any help that can be provided.
0
Answers
-
you should trigger this from changes in the underlying table, not the flowfield. I'd suggest adding some code after importing the xml file into your replacement cost table to recalculate all the records in the customer pricing table that are affected.0
-
MBerger,
Thanks for the suggestion. I put in code in the XMLport to calculate the replacement cost and the unit price after the import. It works like a charm. I appreciate your help.
blh0
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