Options

Forcing an entry into record

McCoyMcCoy Member Posts: 39
A client has asked that we validate a field in the purchase line to determine if a date has been entered or if they want the default 12/31/9999 date - I got this working BUT they have an opportunity to select a line/record in a sub form and request Multiple lines/records be created from that line(purchase line), they do not want to verify these lines for the date as the new lines should default to the date supplied on the first line. The creation of the multiple lines is made via a processing only report. I got the first part working using a onValidate trigger on the purchase line table but I can't figgure out how to bypass the check on the newly generated lines. I tried adding a field to the file, I tried adding a global variable - nothing seems to work - please somebody have an idea on how to get this done [-o< - I could do this easily in other languages but I keep running into walls with Navision. ](*,)

Comments

  • Options
    DenSterDenSter Member Posts: 8,304
    MyRec.MyField := MyValue; // does not run the validation code
    MyRec.VALIDATE(MyField,MyValue); // runs the validation code
    
    To 'bypass' field validation code you can simply assign a value to the field. If you want certain lines of code to only run if the user modifies the field value, you put the code into the following IF statement:
    IF CurrFieldNo <> 0 THEN BEGIN
      // the code that only runs if the user is actually on the current field
    END;
    
    Similarly, you can use this to determine if you should default the field for automatic processes:
    IF CurrFieldNo = 0 THEN BEGIN
      // the code that only runs if the user is NOT on the current field
    END;
    

    By the way... are you the 'real' McCoy? :lol:
  • Options
    McCoyMcCoy Member Posts: 39
    My validation is part of the table as the subform just uses the table logic for validation - this is fine when they are adding one record at a time - it is when the processing-only report builds records for them that I have the problem - since the validation is done at the table level I check for 0D and do a pop-up Confirm do set the default date. Howver I can't get it to not validate during the table insert. I tried loading the value before the insert command but I think it grabs the record during the 'RECORD.INIT' processes and forces all validation routines at that point or does it? I am fairly new to Navision (lots of other languages but less than 6months on Navision - although I have passed both tests) so I get frustrated when I can't control what the system is doing or see it - I have tried to watch it through debugger to see when it hits this but can't seem to find it.

    I am not the 'real' McCoy - I just married one!
  • Options
    DenSterDenSter Member Posts: 8,304
    Use the SetHideValidation function in the sales header/line tables to steal this from. Then modify your CONFIRM to only do the popup if HideValidation is TRUE and set it to another default value when it is FALSE. Then in your report you set the value of the boolean to false and you should be set.

    Oh, and INSERT accepts a boolean parameter that controls whether to run the OnInsert code or not. INSERT(TRUE) runs the code, INSERT(FALSE) does not run the code.
Sign In or Register to comment.