Using setrange in report.

IPGRuss
Member Posts: 12
I have a report that uses the Item Ledger Entry line and I need to pull some information from the Item table at the same time. I'm trying to use setrange to accomplish this but I think I'm missing something:
Thanks in advance for any help.
"Item".SETRANGE("Item Ledger Entry"."Item No."); IF "Item".FIND('-') THEN BEGIN rootcost := "Item"."Material Cost"; END;
Thanks in advance for any help.
0
Comments
-
Use Item.GET instead of SETRANGE and FIND:
IF Item.GET("Item Ledger Entry"."Item No.") THEN rootcost := Item."Material Cost";
0 -
Hi,
If You do it in trigger - On AfterGetRecord in dataitem "Item ledger entry" then code should be:
IF "Item".GET("Item ledger entry"."Item No.") THEN
rootcost := "Item"."Material Cost"
ELSE
rootcost :=0; //probably never use - You can delete this line
There is more other solution to do this ,but this will work.
Regards0 -
Hi,
The setrange needs at least two parameters to work e.g. setrange( Onwhat, RangeValue,... )
Because you're looking up a table which the code is a primary key
the following code would be betterif item.get("Item Ledger Entry"."Item No.") then rootcost := Item."Material Cost" else rootcost := 0;
Hope this helps0 -
It comes back saying Material Cost is not defined. I have Item defined in my globals as record of the Item table. Do I need to define this field somewhere else?0
-
I thought it was a field you added. Use Item."unit cost". To find out all fields on a record use the C/AL Symbol Menu (F5)0
-
I did create Material Cost, had a typo, it's working now, thanks.0
-
So it's now pulling the correct value for Material Cost but now, if Material Cost = 0 it should pull the Cost Amount from the Item Ledger Entry, this just returns 0:
IF item.GET("Item Ledger Entry"."Item No.") THEN rootcost := item."Material Cost (FYI)" ELSE rootcost := "Item Ledger Entry"."Cost Amount (Actual)"
0 -
I realized I wasn't checking to see if the Material Cost = 0, I am now, but this doesn't seem to be working:
IF item.GET("Item Ledger Entry"."Item No.") THEN IF item."Material Cost (FYI)" = 0 THEN rootcost := item."Material Cost (FYI)" ELSE rootcost := "Item Ledger Entry"."Cost Amount (Actual)"; roottotal := roottotal + rootcost;
0 -
Hi
You have your "if" the wrong way around if cost = 0 then root = cost.
should be
if cost = 0 then
root := item ledger entry
else
root := cost;0 -
Did you call CALCFIELDS for "Item Ledger Entry"."Cost Amount (Actual)" ?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