global variable

redStripe
redStripe Member Posts: 83
Hello,
I got a problem with global boolean variable, wich I defined on a table.
I set the variable in an onValidate-Trigger to true and after that I want
to check the value of the variable in the onModify Trigger. There is the
value always false, even the value in the onValidate Trigger is true.
It seems that Navision don't save the value. Is that normal or do I
something wrong?

Thanks in advance.

Regards,
RedStripe

Comments

  • ta5
    ta5 Member Posts: 1,164
    Hi

    As soon as you quit the trigger the globals have gone.
    However, if for example you set the var in a OnValidate-Trigger and this trigger calls the OnModify-Trigger, then it works.

    If you need more persistent globals, you could set/get vars in a single instance code unit or if it is only for a table status you could use a table field for that.

    Hope this helps
    Thomas
  • JoeK
    JoeK Member Posts: 53
    sure?

    I think the globals are saved as long as your instance exists.

    redstripe: where or in what case do you use this? (code example)
  • kine
    kine Member Posts: 12,562
    And main thing is, that the MODIFY and VALIDATE must be called from same Record Variable...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Miklos_Hollender
    Miklos_Hollender Member Posts: 1,598
    redStripe,

    are you sure you really need it? If what you actually want is to to tell OnModify that "field X has been changed", you can just check it from OnModify via IF rec.Something <> xRec.Something THEN
  • DenSter
    DenSter Member Posts: 8,307
    Variables are created in a certain context. A global variable is only global inside the scope of the object that you're working with. If you set a global variable to TRUE in ItemOne, that value will not be accessible in ItemTwo.
  • redStripe
    redStripe Member Posts: 83
    Thanks for all answers.
    I solved it with this:
    IF rec.Something <> xRec.Something THEN
    

    Regards.
    R.