Report updating values depending on item variation

JlT
Member Posts: 18
Hello!
I´m trying to create a report updating prices in a table with variations of items.
IF NewPriceNormalCall <> 0 THEN BEGIN
"Contract Standard Price".SETRANGE("Price Type","Price Type"::"Normal Call");
NewPrice := NewPriceAlarmCall + "Contract Standard Price"."Unit Price";
"Contract Standard Price"."Unit Price" := NewPrice;
"Contract Standard Price".MODIFY;
END;
IF NewPriceExtraCall <> 0 THEN BEGIN
"Contract Standard Price".SETRANGE("Price Type","Price Type"::"Extra Call");
NewPrice := NewPriceExtraTime + "Contract Standard Price"."Unit Price";
"Contract Standard Price"."Unit Price" := NewPrice;
"Contract Standard Price".MODIFY;
END;
As long as only condition one is met the update runs smoothly, but if option 2 runs, both variations gets modified. I guess I´m doing something wrong with the filters but I can´t figure out what.
I´m trying to create a report updating prices in a table with variations of items.
IF NewPriceNormalCall <> 0 THEN BEGIN
"Contract Standard Price".SETRANGE("Price Type","Price Type"::"Normal Call");
NewPrice := NewPriceAlarmCall + "Contract Standard Price"."Unit Price";
"Contract Standard Price"."Unit Price" := NewPrice;
"Contract Standard Price".MODIFY;
END;
IF NewPriceExtraCall <> 0 THEN BEGIN
"Contract Standard Price".SETRANGE("Price Type","Price Type"::"Extra Call");
NewPrice := NewPriceExtraTime + "Contract Standard Price"."Unit Price";
"Contract Standard Price"."Unit Price" := NewPrice;
"Contract Standard Price".MODIFY;
END;
As long as only condition one is met the update runs smoothly, but if option 2 runs, both variations gets modified. I guess I´m doing something wrong with the filters but I can´t figure out what.
0
Best Answer
-
SETRANGE and SETFILTER have no effect if you don't also use a statement to retrieve the data : You are missing a FINDSET, FINDFIRST, FINDLAST or similar to actually get something from the database.5
Answers
-
After reading the code, I dont really get what you are trying to achieve, and I doubt anybody here will.
Your SETRANGE's in this snippet actually do nothing at all.
However feel free to PM me the object, if you mind sharing it in the thread. This shouldn't take long.Austrian NAV/BC Dev0 -
It would be good if you posted the object. We're only guessing at what some of the code is. The NewPrice conditionals, for example, are those functions or variables? Can't understand custom code snippets without context.0
-
SETRANGE and SETFILTER have no effect if you don't also use a statement to retrieve the data : You are missing a FINDSET, FINDFIRST, FINDLAST or similar to actually get something from the database.5
-
Thank you! As I guessed I was using the filters wrong, not including some sort of FIND. Now it works perfectly. I also try to give more context next time.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