What wrong with the code

mkpjsr
Member Posts: 587
Hi all,
I am trying to fetch the line amount of sales line having Item Charges, so i have written the following code but its giving value 0. I have written the code under Integer OnPreSection trigger
globals i have used:
SalesInvoiceLine->Rec->Sales Invoice Line
FCharges->Decimal
//'FORWARDING CHARGES' :- A Item Charges No. i have created
IF SalesInvoiceLine.FIND('-') THEN
BEGIN
IF SalesInvoiceLine."No."='FORWARDING CHARGES' THEN
BEGIN
//SalesInvoiceLine.CALCFIELDS("Line Amount");
FCharges:=SalesInvoiceLine."Line Amount";
END;
END;
If i am removing the comment from the fifth line its fetching the line amount of the first line. Actually i want to fetch the line amount of the line having item no as 'FORWARDING CHARGES'
Can anubody tell me whats the problem.
I am trying to fetch the line amount of sales line having Item Charges, so i have written the following code but its giving value 0. I have written the code under Integer OnPreSection trigger
globals i have used:
SalesInvoiceLine->Rec->Sales Invoice Line
FCharges->Decimal
//'FORWARDING CHARGES' :- A Item Charges No. i have created
IF SalesInvoiceLine.FIND('-') THEN
BEGIN
IF SalesInvoiceLine."No."='FORWARDING CHARGES' THEN
BEGIN
//SalesInvoiceLine.CALCFIELDS("Line Amount");
FCharges:=SalesInvoiceLine."Line Amount";
END;
END;
If i am removing the comment from the fifth line its fetching the line amount of the first line. Actually i want to fetch the line amount of the line having item no as 'FORWARDING CHARGES'
Can anubody tell me whats the problem.
0
Comments
-
You have to loop through the record set that is returned by the FIND using a REPEAT..UNTIL. You could also try doing a CALCSUMS if the current key supports it.
And you really shouldn't hard code the No. field in the code like that.0 -
matttrax wrote:You have to loop through the record set that is returned by the FIND using a REPEAT..UNTIL. You could also try doing a CALCSUMS if the current key supports it.
And you really shouldn't hard code the No. field in the code like that.
Further move the code to "OnAfterGetRecord" rather than OnPreSectionCA Sandeep Singla
http://ssdynamics.co.in0 -
matttrax wrote:You have to loop through the record set that is returned by the FIND using a REPEAT..UNTIL. You could also try doing a CALCSUMS if the current key supports it.
And you really shouldn't hard code the No. field in the code like that.
if i am using a loop then its causing another problem as some sections are not properly displayed0 -
Have you used setrange/setfilter for type = Charge (Item). Further apply filter for your "Forwarding Charges" for field "No." and then try.CA Sandeep Singla
http://ssdynamics.co.in0 -
Yeah, didn't realize this was on a report. You'll need to properly set your filters. The report will handle the looping for you.0
-
matttrax wrote:Yeah, didn't realize this was on a report. You'll need to properly set your filters. The report will handle the looping for you.
i have tried this code but its not working
SalesInvoiceLine.RESET;
//SalesInvoiceLine.SETRANGE(SalesInvoiceLine."Document No.","Sales Invoice Header"."No.");
SalesInvoiceLine.SETRANGE(SalesInvoiceLine.Type,SalesInvoiceLine.Type::"Charge (Item)");
SalesInvoiceLine.SETFILTER(SalesInvoiceLine."No.",'FORWARDING CHARGES');
CCharges:=SalesInvoiceLine."Line Amount";
still its giving line amount from 1st line.0 -
-
ssingla wrote:Where is Find('-') or Findset?
SalesInvoiceLine.RESET;
//SalesInvoiceLine.SETRANGE(SalesInvoiceLine."Document No.","Sales Invoice Header"."No.");
SalesInvoiceLine.SETRANGE(SalesInvoiceLine.Type,SalesInvoiceLine.Type::"Charge (Item)");
SalesInvoiceLine.SETFILTER(SalesInvoiceLine."No.",'FORWARDING CHARGES');
IF SalesInvoiceLine.FIND('-') THEN
begin
CCharges:=SalesInvoiceLine."Line Amount";
end;
if i am writing this, still the result is same0 -
mkpjsr wrote:ssingla wrote:Where is Find('-') or Findset?
SalesInvoiceLine.RESET;
//SalesInvoiceLine.SETRANGE(SalesInvoiceLine."Document No.","Sales Invoice Header"."No.");
SalesInvoiceLine.SETRANGE(SalesInvoiceLine.Type,SalesInvoiceLine.Type::"Charge (Item)");
SalesInvoiceLine.SETFILTER(SalesInvoiceLine."No.",'FORWARDING CHARGES');
IF SalesInvoiceLine.FIND('-') THEN
begin
CCharges:=SalesInvoiceLine."Line Amount";
end;
if i am writing this, still the result is samematttrax wrote:You have to loop through the record set that is returned by the FIND using a REPEAT..UNTIL.NAV - Norton Anti Virus
ERP Consultant (not just Navision) & Navision challenger0 -
idiot wrote:mkpjsr wrote:ssingla wrote:Where is Find('-') or Findset?
SalesInvoiceLine.RESET;
//SalesInvoiceLine.SETRANGE(SalesInvoiceLine."Document No.","Sales Invoice Header"."No.");
SalesInvoiceLine.SETRANGE(SalesInvoiceLine.Type,SalesInvoiceLine.Type::"Charge (Item)");
SalesInvoiceLine.SETFILTER(SalesInvoiceLine."No.",'FORWARDING CHARGES');
IF SalesInvoiceLine.FIND('-') THEN
begin
CCharges:=SalesInvoiceLine."Line Amount";
end;
if i am writing this, still the result is samematttrax wrote:You have to loop through the record set that is returned by the FIND using a REPEAT..UNTIL.
Actually i am using this code on report so if i am using loop then file i am getting the records but some sections of the reports are not getting displayed. Can u plz suggest some solution.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