Update Line from Header automatically?

Tiwaz
Member Posts: 98
Hi guys.
I have a table Header (prim.key=No.) and Line (prim.key=Line No., Header No.) where Header No. is No. from header table because Header Card is connected to Lines listpart using this field.
In my Line table, in OnInsert() i have the code which makes sure i get the date from Header on Line:
IF Header.GET("Header No.") THEN
Date := Header.Date;
It works fine when i first enter the Date in Header and insert something on Line.
But when I wish to change the date on Header it doesn't get changed on Line.
What should I do?
I want, when i change the Date on Header Card, for Nav to check if there are existing lines for that header, and if there are, to ask if I want to change the date. If I confirm, date gets changed on Line. If not, it doesn't.
I really appreciate your help
Thanks
I have a table Header (prim.key=No.) and Line (prim.key=Line No., Header No.) where Header No. is No. from header table because Header Card is connected to Lines listpart using this field.
In my Line table, in OnInsert() i have the code which makes sure i get the date from Header on Line:
IF Header.GET("Header No.") THEN
Date := Header.Date;
It works fine when i first enter the Date in Header and insert something on Line.
But when I wish to change the date on Header it doesn't get changed on Line.
What should I do?

I want, when i change the Date on Header Card, for Nav to check if there are existing lines for that header, and if there are, to ask if I want to change the date. If I confirm, date gets changed on Line. If not, it doesn't.
I really appreciate your help

Thanks

0
Best Answers
-
You should add this code in the header:
in the section: Order Date - OnValidate()
as this code does not exist yet, you have to write it yourself.IF User.Loves('Edo') THEN ok() ELSE currReport.genSkip;5 -
Have a look at how this is done in standard NAV - e.g. "Shipment Date" on Sales Header & Sales Line works in a similar way.5
-
The code in the header should ask the user if he/she wants to update all lines, if yes, with a salesline.SETFILTER you need to filter out the lines for this order only, and loop through these lines and update the orderdate with the VALIDATE command with the new order date.
As Kishorm said, you can find a clear example on the field Shipment Date.IF User.Loves('Edo') THEN ok() ELSE currReport.genSkip;5
Answers
-
You should add this code in the header:
in the section: Order Date - OnValidate()
as this code does not exist yet, you have to write it yourself.IF User.Loves('Edo') THEN ok() ELSE currReport.genSkip;5 -
Have a look at how this is done in standard NAV - e.g. "Shipment Date" on Sales Header & Sales Line works in a similar way.5
-
The code in the header should ask the user if he/she wants to update all lines, if yes, with a salesline.SETFILTER you need to filter out the lines for this order only, and loop through these lines and update the orderdate with the VALIDATE command with the new order date.
As Kishorm said, you can find a clear example on the field Shipment Date.IF User.Loves('Edo') THEN ok() ELSE currReport.genSkip;5 -
This code on Header solved my problem
OnInsert()
...
...
Posting Date - OnValidate()
UpdateLines(FIELDCAPTION("Posting Date"),CurrFieldNo <> 0);
...
...
LOCAL LinesExist() : Boolean
Line.RESET;
Line.SETRANGE("Header No.","No.");
EXIT(Line.FINDFIRST);
LOCAL UpdateLines(ChangedName : Text[250];AskQuestion : Boolean)
IF NOT LinesExist THEN
EXIT;
IF AskQuestion THEN
Question := STRSUBSTNO(Txt1,ChangedName);
IF GUIALLOWED THEN
IF DIALOG.CONFIRM(Question,TRUE) THEN BEGIN
END
ELSE
EXIT;
Line.LOCKTABLE;
MODIFY;
Line.RESET;
Line.SETRANGE("Header No.","No.");
IF Line.FINDSET THEN BEGIN
REPEAT
CASE ChangedName OF
FIELDCAPTION("Posting Date"):
IF Line."Header No." <> '' THEN BEGIN
Line.VALIDATE("Price Date","Posting Date");
Line.MODIFY;
END;
END;
UNTIL Line.NEXT = 0;
END;2
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