Update Line from Header automatically?

TiwazTiwaz 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 :)

Best Answers

Answers

  • TiwazTiwaz Member Posts: 98
    @edoderoo Are you saying that I should use the code from Order date in Sales Header in my Header?
    :)
    I have done this and created function needed but it only displays message without actually changing the date on my Line :/
  • TiwazTiwaz Member Posts: 98
    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;
Sign In or Register to comment.