Hi All,
How to find out the current record present in sales order based on this record I want to add the new line of item charges automatically and I want to write the code by creating the function in code unit 80 and want to call it for the post button because when I hit the post button the new line of item charges should be added automatically
for example 1st line as item and it's document no. is 1900
and 2nd line as charge(Item) and it's document no. is taking as null
please suggest me to achieve this
0
Answers
-Mohana
http://mohana-dynamicsnav.blogspot.in/
https://www.facebook.com/MohanaDynamicsNav
could you please tell me the meaning of this error
Are you hard coded line no. to 20000?
-Mohana
http://mohana-dynamicsnav.blogspot.in/
https://www.facebook.com/MohanaDynamicsNav
what have you done to get this error?
-Mohana
http://mohana-dynamicsnav.blogspot.in/
https://www.facebook.com/MohanaDynamicsNav
could you please tell me clearly
I am new to navision
-Mohana
http://mohana-dynamicsnav.blogspot.in/
https://www.facebook.com/MohanaDynamicsNav
WITH SalesHeader DO BEGIN
GRecSalesLine.RESET;
GRecSalesLine.SETRANGE("Document Type","Document Type");
GRecSalesLine.SETRANGE("Document No.","No.");
GRecSalesLine.SETRANGE(Type,GRecSalesLine.Type::"Charge (Item)");
IF GRecSalesLine.FINDFIRST THEN BEGIN
NewItemChargeAssignment.INIT;
NewItemChargeAssignment."Document Type" := GRecSalesLine."Document Type"::Order;
NewItemChargeAssignment."Document No." := "No.";
NewItemChargeAssignment."Document Line No." := GRecSalesLine."Line No.";
NewItemChargeAssignment."Line No." := GRecSalesLine."Line No.";
NewItemChargeAssignment."Applies-to Doc. Line No." := NewItemChargeAssignment."Line No.";
NewItemChargeAssignment."Applies-to Doc. No." := GRecSalesLine."Document No.";
NewItemChargeAssignment."Applies-to Doc. Type" := GRecSalesLine."Document Type"::Order;
NewItemChargeAssignment."Item Charge No." := 'I-FREIGHT';
NewItemChargeAssignment."Item No." := SalesLine."No.";
NewItemChargeAssignment.Description := SalesLine.Description;
NewItemChargeAssignment.VALIDATE("Qty. to Assign",1);
NewItemChargeAssignment.VALIDATE("Unit Cost",GRecSalesLine."Amount Including VAT");
NewItemChargeAssignment.VALIDATE("Amount to Assign",GRecSalesLine."Amount Including VAT");
NewItemChargeAssignment.INSERT;
END;
END;
I have written the code like this because I don't want to use the item charge assignment feature without using that feature I want to invoice the item charges by assigning the charges to the item
But before I want to invoice this record of item charges get inserted in 5809 table
First find out why line 10000 is existing. If all according to plan then something like this should solve it:
IF GRecSalesLine.FINDFIRST THEN BEGIN
clear(NewItemChargeAssignment);
NewItemChargeAssignment.setrange("Document Type",GRecSalesLine."Document Type"::Order);
NewItemChargeAssignment.setrange("Document No.","No.");
NewItemChargeAssignment.setrange("Document Line No.",GRecSalesLine."Line No.");
if NewItemChargeAssignment.findlast then
NewLineNo := NewItemChargeAssignment."line no." + 10000
else
NewLineNo := 10000;
clear(NewItemChargeAssignment);
NewItemChargeAssignment.INIT;
NewItemChargeAssignment."Document Type" := GRecSalesLine."Document Type"::Order;
NewItemChargeAssignment."Document No." := "No.";
NewItemChargeAssignment."Document Line No." := GRecSalesLine."Line No.";
NewItemChargeAssignment."Line No." := NewLineNo;