can anyone tell me exactly and clearly in deatil so that i can be able to correcly write my code in the correct triggerin nav 2009 r2....with clear explanation?
The links provided give you general information about the triggers available and when they are called. If this isn't sufficient information for you then please state what extra information you require, i.e. what it is specifically that you don't understand.
The links provided give you general information about the triggers available and when they are called. If this isn't sufficient information for you then please state what extra information you require, i.e. what it is specifically that you don't understand.
A trigger is actually a misnomer. It is a callback function that is called by the system in case the corresponding event triggers it. So, for example, the OnInsert function in the Item table is called every time a record is inserted into the Item table. (In this case, if inserting a record through code, you have a choice of suppressing the trigger by calling the INSERT function without a TRUE as its parameter.)
First of all, you need to know that the difference between OnValidate and OnLookup for each field is that
OnValidate gets triggered when you fill something in the field and hit ENTER or just click on another field.
OnLookup is used to do something when you want your field to have lookup button on it (that button with tiny arrow, like when you choose something from drop-down list).
Also, think about when you want your code to be executed and do you have suffincient information to execute it.
For example, if you have fields X, Y, Z and W.
And you want to calculate W = X + Y - Z.
If you put code for this on OnValidate () trigger of Y (for example), it will be calculated when you fill the Y value and hit ENTER ONLY if NAV already knows values for X and Z (in other words if it's already filled).
If they are not filled, NAV will assume that they are 0.
If you enter a value in X afterwards, NAV will not calculate this again because it already took all the values and triggered the code on Y.
If you want W to get calculated every time you change either X, Y or Z,
you can:
a) put W = X + Y - Z on OnValidate for X, Y and Z.
b) put W = X + Y - Z only on Y trigger and then put the function VALIDATE(Y,Y) on OnValidate triggers of X and Z which will jump to Y OnValidate trigger every time you enter something in X or Z fields and execute W = X + Y - Z.
Hope this gives you a basic picture of HOW and WHEN you use certain triggers.
Answers
Hope this would help more than any other documents
Archerpoint India Pvt. Ltd,Chennai.
-Mohana
http://mohana-dynamicsnav.blogspot.in/
https://www.facebook.com/MohanaDynamicsNav
-Mohana
http://mohana-dynamicsnav.blogspot.in/
https://www.facebook.com/MohanaDynamicsNav
OnValidate gets triggered when you fill something in the field and hit ENTER or just click on another field.
OnLookup is used to do something when you want your field to have lookup button on it (that button with tiny arrow, like when you choose something from drop-down list).
Also, think about when you want your code to be executed and do you have suffincient information to execute it.
For example, if you have fields X, Y, Z and W.
And you want to calculate W = X + Y - Z.
If you put code for this on OnValidate () trigger of Y (for example), it will be calculated when you fill the Y value and hit ENTER ONLY if NAV already knows values for X and Z (in other words if it's already filled).
If they are not filled, NAV will assume that they are 0.
If you enter a value in X afterwards, NAV will not calculate this again because it already took all the values and triggered the code on Y.
If you want W to get calculated every time you change either X, Y or Z,
you can:
a) put W = X + Y - Z on OnValidate for X, Y and Z.
b) put W = X + Y - Z only on Y trigger and then put the function VALIDATE(Y,Y) on OnValidate triggers of X and Z which will jump to Y OnValidate trigger every time you enter something in X or Z fields and execute W = X + Y - Z.
Hope this gives you a basic picture of HOW and WHEN you use certain triggers.