"Debit Amount" and "Credit Amount" are calculated fields (FlowFields), you cannot update other fields based on their value, because the value is calculated "On Flight".
I would not do it the way you want it to do. The two amount fields are flowfields, which means the actual values are in another table. You should write your code OnInsert, OnModify, OnDelete ... may be OnValidate.
... I don't recommend this.
I would just calculate it when you open the card form, in a seperate variable. Even, if possible, put it on a seperate form (that way, it's not always calculated, only when you WANT to see it). A typical Statistic form (F9) are usually also variables which are calculated when opening the form... .
I create field Dr/Cr type option,optionstring DR,CR
and write a code on ON validate DR/CR
IF "Debit Amount" > "Credit Amount" THEN
"Dr./Cr." := "Dr./Cr." ::DR
ELSE
"Dr./Cr." := "Dr./Cr." ::CR;
But I will not updated automatically in the card. If i update it from backend then it will reflect in the card.
What can I do ??
Hi Vyanku,
In Navision, often when you try to do something, its best to take a step back, and say "what do I want to achieve" NOT "how do I want to do it".
Reading between the lines, it looks as though what you really want is a field on the Customer card that shows if the customer is in Debit or in Credit. Also maybe you are trying to update this into an actual field in the customer Table (assuming "Dr./Cr." is an option field and not a variable.
This can beter be done by just calculating based on "Balance", and compare this to zero. Then display based on "Balance" > 0.
Also it is not wise (if this is what you are doing), to have a field in a table updated from processing on a form. Rather just have the value calculated when you run the form.
thanks
But how to update the value of DR/CR.??
Suppose balance is become +ve then Dr should be automatically updated from CR to DR. Is there any function for update option value???
thanks
But how to update the value of DR/CR.??
Suppose balance is become +ve then Dr should be automatically updated from CR to DR. Is there any function for update option value???
Its very important if you will start developing in Navision to learn about flowfields and how they work. they are key to the whole application, and you really will not be able to get far unless you first understand how they work.
Once you understand how flow fields work you will understand what we are suggesting.
Flow Fields and Flow Filters are explained clearly in the Navision Manuals. Also once you have read about them, then start playing with a test database and look at fields like Inventory in table 27, and the Balance vs Amount fields in table 15.
Thanks Waldo. It solves my problem.
Will u please tell me what is the difference between Onaftergetrecord() and onaftergetcurrentrecord()???
If I put code on OnValidate() of balance field of form nothing is happend but if I put it on OnAftergetrecord() it works suscessfully. Why?? Becasue if we change the customer (like next costomer) then also OnValidate trigger of balance field is executed.
Will u please explain me the funda behind this triggers???
f we change the customer (like next costomer) then also OnValidate trigger of balance field is executed.
This is not true. OnValidate trigger is called just when the value in the field is changed. Not when you go to another record. And because this field is calculated and is not editable, there is no event which will fire this trigger.
Thanks Waldo. It solves my problem.
Will u please tell me what is the difference between Onaftergetrecord() and onaftergetcurrentrecord()???
If I put code on OnValidate() of balance field of form nothing is happend but if I put it on OnAftergetrecord() it works suscessfully. Why?? Becasue if we change the customer (like next costomer) then also OnValidate trigger of balance field is executed.
Will u please explain me the funda behind this triggers???
Vyanku, what do you mean by this?
If this solves your problem, then you don't need to look at on after.. and other triggers.
So either you don't understand how this solves your problem, OR this is a new topic, in which case you should start a new post.
Answers
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
Navision Technical Consultant
... I don't recommend this.
I would just calculate it when you open the card form, in a seperate variable. Even, if possible, put it on a seperate form (that way, it's not always calculated, only when you WANT to see it). A typical Statistic form (F9) are usually also variables which are calculated when opening the form... .
Eric Wauters
MVP - Microsoft Dynamics NAV
My blog
Hi Vyanku,
In Navision, often when you try to do something, its best to take a step back, and say "what do I want to achieve" NOT "how do I want to do it".
Reading between the lines, it looks as though what you really want is a field on the Customer card that shows if the customer is in Debit or in Credit. Also maybe you are trying to update this into an actual field in the customer Table (assuming "Dr./Cr." is an option field and not a variable.
This can beter be done by just calculating based on "Balance", and compare this to zero. Then display based on "Balance" > 0.
Also it is not wise (if this is what you are doing), to have a field in a table updated from processing on a form. Rather just have the value calculated when you run the form.
The solutions that Eric and I have offered, are in principle the same, and give you exactly what you need.
You are forgiven, my friend O:)
Eric Wauters
MVP - Microsoft Dynamics NAV
My blog
But how to update the value of DR/CR.??
Suppose balance is become +ve then Dr should be automatically updated from CR to DR. Is there any function for update option value???
Its very important if you will start developing in Navision to learn about flowfields and how they work. they are key to the whole application, and you really will not be able to get far unless you first understand how they work.
Once you understand how flow fields work you will understand what we are suggesting.
Flow Fields and Flow Filters are explained clearly in the Navision Manuals. Also once you have read about them, then start playing with a test database and look at fields like Inventory in table 27, and the Balance vs Amount fields in table 15.
OnAfterGetRecord or OnOpenForm (statistics), just update your variable with the right Option value...
Eric Wauters
MVP - Microsoft Dynamics NAV
My blog
Will u please tell me what is the difference between Onaftergetrecord() and onaftergetcurrentrecord()???
If I put code on OnValidate() of balance field of form nothing is happend but if I put it on OnAftergetrecord() it works suscessfully. Why?? Becasue if we change the customer (like next costomer) then also OnValidate trigger of balance field is executed.
Will u please explain me the funda behind this triggers???
This is not true. OnValidate trigger is called just when the value in the field is changed. Not when you go to another record. And because this field is calculated and is not editable, there is no event which will fire this trigger.
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
Vyanku, what do you mean by this?
If this solves your problem, then you don't need to look at on after.. and other triggers.
So either you don't understand how this solves your problem, OR this is a new topic, in which case you should start a new post.
Thanks for reply
So did anyone post a reply for the differences between OnAfterGetRecord & OnAfterGetCurrentRecord ?
Regards
here's a simple answer if you just want it to standout on the customer card
OnFormat(VAR Text : Text[1024];)
IF "Balance ($)" < 0
THEN CurrForm."Balance ($)".UPDATEFORECOLOR(255)
ELSE CurrForm."Balance ($)".UPDATEFORECOLOR(0);
EDIT**Didn't realize it was a post from 2007 :oops:
http://www.BiloBeauty.com
http://www.autismspeaks.org
1.click on help
2.View The C/side Reference guide
3.click on Index tab
4.Scroll to onafter....
http://www.BiloBeauty.com
http://www.autismspeaks.org