Onaftergetrecord trigger
mscalamogna
Member Posts: 3
Hi, I'm new to NAV/BC development and trying to figure out how to use the onpredataitem and onaftergetrecord trigger in a report dataset. I have read the online documentation and also used the txt2al tool to look at the code used to generate some of the reports (sales invoice, detail trial balance).. I'm still having a hard time wrapping my mind around how this would work. Here is the code I'm working with, I have three tables: sales invoice header, sales invoice line and location. I am trying to figure out how to use the onpredataitem and onaftergetrecord triggers to pull the location name rather than adding another dataitem. The code I have today is below...
Thanks in advance for your help!
report 50116 "Test Report"
{
UsageCategory = Administration;
ApplicationArea = All;
RDLCLayout = 'rdl_layouts\test.rdl';
dataset
{
dataitem("Sales Invoice Header"; "Sales Invoice Header")
{
RequestFilterFields = "Document Date";
column(No_; "No.") { }
column(Document_Date; "Document Date") { }
column(Posting_Date; "Posting Date") { }
column(Sell_to_Customer_Name; "Sell-to Customer Name") { }
dataitem("Sales Invoice Line"; "Sales Invoice Line")
{
DataItemLink = "Document No." = field ("No.");
column(Item_No_; "No.") { }
column(Description; Description) { }
dataitem(Location; Location)
{
//is there a way to use an onpredataitem and onaftergetrecord trigger to pull the location name?
DataItemLink = "Code" = field ("Location Code");
column(Name; Name) { }
}
}
}
}
}
Thanks in advance for your help!
report 50116 "Test Report"
{
UsageCategory = Administration;
ApplicationArea = All;
RDLCLayout = 'rdl_layouts\test.rdl';
dataset
{
dataitem("Sales Invoice Header"; "Sales Invoice Header")
{
RequestFilterFields = "Document Date";
column(No_; "No.") { }
column(Document_Date; "Document Date") { }
column(Posting_Date; "Posting Date") { }
column(Sell_to_Customer_Name; "Sell-to Customer Name") { }
dataitem("Sales Invoice Line"; "Sales Invoice Line")
{
DataItemLink = "Document No." = field ("No.");
column(Item_No_; "No.") { }
column(Description; Description) { }
dataitem(Location; Location)
{
//is there a way to use an onpredataitem and onaftergetrecord trigger to pull the location name?
DataItemLink = "Code" = field ("Location Code");
column(Name; Name) { }
}
}
}
}
}
0
Best Answer
-
Great

For help, do not use PM, use forum instead, perhaps other people have the same question, or better answers.5
Answers
-
Hi @mscalamogna
You can on either sales invoice header or sales invoice line add a local variable for Type Record and subtype Location.
Then onAfterGetRecord you can added code like:IF NOT Location.GET("Sales Invoice Line"."Location Code") THEN CLEAR(Location)For help, do not use PM, use forum instead, perhaps other people have the same question, or better answers.1 -
I've tried this a couple of different ways, still having trouble. Is there any way you can post what the entire trigger should look like? I am completely new to this and really struggling to grasp it... I really appreciate your help. I'm not a developer by trade... lol.0
-
WAIT. I got it. You literally did write what the entire trigger should look like

Thank you! Here is where I landed... seems to be working
trigger OnAfterGetRecord()
var
slsLocation: Record Location;
begin
if not slsLocation.Get("Sales Line"."Location Code") then
clear(slsLocation) else
locationName := slsLocation.Name
end;
0 -
Great

For help, do not use PM, use forum instead, perhaps other people have the same question, or better answers.5
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
- 322 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
