Tracing where a Global Variable is being modified

CalicoCalico Member Posts: 31
In NAV 5.0 Employee table I have created a new Global Variable (Boolean). It is set to true by the OnValidate triggers of various fields and in the OnModify trigger, a function is run if it is true. I have tested and it is set correctly by the OnValidate triggers but when it reaches the onModify it is false (No). I know there is nothing setting it to false because it is a new variable I have created. There is no CLEARALL statement in either the table or form code (I have exported them as text and searched. Can anyone suggest how I can track down what is changing it? I have tried changing a field which sets the global to true and then immediately doing a page-down to trigger the OnModify but something is resetting it in between these two functions.

Answers

  • krikikriki Member, Moderator Posts: 9,110
    Very weird.
    I think the best thing you can do is using the debugger and adding a watch on that global to see when it changes.
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • CalicoCalico Member Posts: 31
    I've tried that. I put a break point in a validation routine where the variable is set to TRUE and then change the value of that field on the form. The debugger window starts and I as I step through the code I can see the value of the variable being changed from No to Yes. The debugger then returns me to the form waiting for further input. I pg-down to the next record and am returned to the debugger in the on Modify trigger where the variable has already changed back to No (FALSE)! As you say, very weird. I think I need to look at another way of achieving the same result.
  • BeliasBelias Member Posts: 2,998
    Try to check if you have defined a local variable in the trigger that has the same name as the global variable :-k
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • kapamaroukapamarou Member Posts: 1,152
    I think i'ts normal. Between the validate and the modify the variables are cleared.
    You could add your variable as a field.
  • BeliasBelias Member Posts: 2,998
    kapamarou wrote:
    I think i'ts normal. Between the validate and the modify the variables are cleared.
    You could add your variable as a field.
    #-o =D> You're right
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • CalicoCalico Member Posts: 31
    Belias - I've checked that. I've also tried changing the name of the variable but the result is the same. kapamarou I have checked and you appear to be right - but why?
  • kapamaroukapamarou Member Posts: 1,152
    Because I think that when you use the Rec variable of the form, at some point it gets reset. It's different than using your record variable like this:

    SalesLineVar.VALIDATE("No.");
    SalesLineVar.MODIFY(TRUE);
    SalesLineVar.FunctionToMessageVariable;

    In such a scenario the variable remains.

    I think it causes some issues in some cases but somehow I believe it's better that it happens like that.
  • CalicoCalico Member Posts: 31
    Thanks for everyone's help.
  • krikikriki Member, Moderator Posts: 9,110
    kapamarou wrote:
    I think i'ts normal. Between the validate and the modify the variables are cleared.

    Correct. The globals are cleared between the OnValidate and the OnModify (just tried it out). BUT the records in a globally declared temptable are NOT cleared! This is the code I tried and it works:
    OnInsert()
    tmpLanguage.FINDFIRST;
    MESSAGE('%1',tmpLanguage.Code);
    
    int - OnValidate()
    tmpLanguage.Code := 'xyz';
    tmpLanguage.INSERT(FALSE);
    MESSAGE('%1',tmpLanguage.Code);
    
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


Sign In or Register to comment.