problem With Sales Line

MRQ
Member Posts: 73
Hi
I am trying to write this field from Sales line to the another table called Accommodation the field is "Documant Type" "documant No." "Line No."
and then give "No series" to fourth field called "No." i write the follwing code to do this
In the salse line Form i add button and write the following code in onPush event
Call function called InsertAccom take the prameter Rec
and this is the code in the function InsertAccom this function take parameter (VAR salesLIne : Record "Sales Line")
to filed "No."
The problem is that when i select seles line from the sales order and press
the button every thing goes right New Rec was Inserted in the Accommodation Table And Take New No." but if i select another sales line and press the button this line take the same "No." of the previous Rec
Unless I close The sales order Form and open it again
and then select sales line and press the button in this case the New Accommodation Rec take New" No."
I am trying to write this field from Sales line to the another table called Accommodation the field is "Documant Type" "documant No." "Line No."
and then give "No series" to fourth field called "No." i write the follwing code to do this
In the salse line Form i add button and write the following code in onPush event
Call function called InsertAccom take the prameter Rec
Accommodation.InsertAccom(Rec); FORM.RUN(FORM::"Accommodation Card",Accommodation);
and this is the code in the function InsertAccom this function take parameter (VAR salesLIne : Record "Sales Line")
InsertAccom(VAR salesLIne : Record "Sales Line") INIT; "Documant No." :=salesLIne."Document No."; "Documant Type" :=salesLIne."Document Type"; "Line No.":=salesLIne."Line No."; INSERT(TRUE);and in the on insert triger write the following cade to give the "No. serise"
to filed "No."
IF "No."='' THEN BEGIN TravelSetup.GET; TravelSetup.TESTFIELD(TravelSetup."Accommodation No." ); NoSeriesMgt.InitSeries(TravelSetup."Accommodation No.","No. Series",0D,"No.","No. Series"); END;
The problem is that when i select seles line from the sales order and press
the button every thing goes right New Rec was Inserted in the Accommodation Table And Take New No." but if i select another sales line and press the button this line take the same "No." of the previous Rec
Unless I close The sales order Form and open it again
and then select sales line and press the button in this case the New Accommodation Rec take New" No."
0
Comments
-
I suppose there is a
WITH AccomLine do begin INIT;
there?
Use CLEAR instead of INIT. Or maybe RESET, but I always use CLEAR...
in the C/AL help of INIT:Comments
The system does not initialize primary key or timestamp fields.
Do It Yourself is they key. Standard code might work - your code surely works.0 -
The button is on the header form, and Rec on the Header is a record in the Sales Header table. If you want to do something with the sales line, you should check the line button and see how Navision accesses the line records.0
-
Problem is the INIT and clearing PK. Correct code is:
INIT; "Documant No." :=salesLIne."Document No."; "Documant Type" :=salesLIne."Document Type"; "Line No.":=salesLIne."Line No."; "No." := ''; INSERT(TRUE);
0 -
thanx you Shenpen, kine
you are right the Problem is the INIT and clearing PK.
now its working thamk alot
dear DenSter the button is on the sales line not in the header0 -
Then you have a customized form. The standard sales order form does not have buttons on the subform.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