Options

Update Line from Header with use of dialog

TiwazTiwaz Member Posts: 98
Hi guys. :) I recently had a problem where I wanted to automatically update Date on my Line when I change the date on Header. Also, I wanted to display a dialog that will ask me if I want to change the date since there are already some Lines for that header. I solved it by adding this code to my Header table. Cheers :)



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;



Comments

  • Options
    KishormKishorm Member Posts: 921
    Hi @Tiwaz, it's great that you posted the solution to your original issue but it would be better to post this onto the original post rather than create a new one to make it easier for people to find the solution to the issue in your original post.
Sign In or Register to comment.