Skip Code Execution in OnValidate Trigger

eskayeskay Member Posts: 11
edited 2011-05-20 in Navision Attain
Hello,
I have a problem with the OnValidate Trigger in a table.

When I select a new Data Entry for exampe "No." in a table I execute some code in the OnValidate Trigger of the field
and insert some "option lines" in an related table.
(OnVALIDATE)...
  IF XtAttributeLines_loc.FIND('-') THEN BEGIN
    REPEAT
      XtAttributeLines2_loc.INIT;
      XtAttributeLines2_loc.TRANSFERFIELDS(XtAttributeLines_loc);
      XtAttributeLines2_loc.Type := Type;
      XtAttributeLines2_loc."No." := "No.";
      XtAttributeLines2_loc."Item No." := "Item No.";
      IF NOT XtAttributeLines2_loc.INSERT THEN
        XtAttributeLines2_loc.MODIFY;
    UNTIL XtAttributeLines_loc.NEXT = 0;
  END;


Now I have a problem when the "No" Entry is terminated. From system the message "Do you want to overwrite data y/n"
is displayed. When I select "No" my "Validate Code" is always executed and I have some Option Data Lines in the table which
I only want to inser on the "Yes" option of the System Message.

Is it possible to "catch" the system Message "Overwrite Data y/n" and skip the validation code if I select No?

It is a little bit difficult to explain but I hope someone can figure it out.

Thx
Siggi

Comments

  • ufukufuk Member Posts: 514
    Do you receive an overwrite or rename message? Where do you receive it? On insert etc?
    Ufuk Asci
    Pargesoft
  • SavatageSavatage Member Posts: 7,142
    quickly looking perhaps it's the transferfields line.

    you transfer the fields then under the line you are setting the type, item no, etc again?
  • kinekine Member Posts: 12,562
    That is the problem when you are changing related tables in the OnValidate trigger. It is much better to do these changes in OnModify/OnInsert trigger instead.
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • eskayeskay Member Posts: 11
    Thx..

    the simpliest solution is always the last on the mind :D

    Of course this way is much more useable.
Sign In or Register to comment.