Option Dr/Cr in customer card

vyankuvyanku Member Posts: 791
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 ??

Answers

  • kinekine Member Posts: 12,562
    "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".
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • vyankuvyanku Member Posts: 791
    Then What should I do to display DR, CR on customer card.(Wether the customer balance is DR or CR) ???
  • vikram7_dabasvikram7_dabas Member Posts: 611
    firstly u have to usee the calcfield function bcoz credit amount and debit amount r the flow fields
    Vikram Dabas
    Navision Technical Consultant
  • WaldoWaldo Member Posts: 3,412
    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... .

    Eric Wauters
    MVP - Microsoft Dynamics NAV
    My blog
  • David_SingletonDavid_Singleton Member Posts: 5,479
    vyanku wrote:
    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.
    David Singleton
  • vyankuvyanku Member Posts: 791
    But I just want to show the Dr or CR .So that client can understand that Customer balance is DR or CR.
  • David_SingletonDavid_Singleton Member Posts: 5,479
    hey Eric, sorry forth ecross post, you were faster :D
    David Singleton
  • David_SingletonDavid_Singleton Member Posts: 5,479
    vyanku wrote:
    But I just want to show the Dr or CR .So that client can understand that Customer balance is DR or CR.

    The solutions that Eric and I have offered, are in principle the same, and give you exactly what you need.
    David Singleton
  • WaldoWaldo Member Posts: 3,412
    hey Eric, sorry forth ecross post, you were faster :D

    You are forgiven, my friend O:)

    Eric Wauters
    MVP - Microsoft Dynamics NAV
    My blog
  • vyankuvyanku Member Posts: 791
    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???
  • David_SingletonDavid_Singleton Member Posts: 5,479
    vyanku wrote:
    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.
    David Singleton
  • vyankuvyanku Member Posts: 791
    But here DR/CR is not a flow field it is option field having code on onvalidate trigger. Here I am not using flowfield.
  • WaldoWaldo Member Posts: 3,412
    We are suggesting to delete your field in the table, and to create a variable on your form.

    OnAfterGetRecord or OnOpenForm (statistics), just update your variable with the right Option value...

    Eric Wauters
    MVP - Microsoft Dynamics NAV
    My blog
  • vyankuvyanku Member Posts: 791
    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???
  • kinekine Member Posts: 12,562
    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.
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • David_SingletonDavid_Singleton Member Posts: 5,479
    vyanku wrote:
    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.
    David Singleton
  • vyankuvyanku Member Posts: 791
    Ok . Actually My problem is solved. I just want another information. For taht I will post new topic.
    Thanks for reply
  • edisonledisonl Member Posts: 25
    Hi Mr Vyanku,

    So did anyone post a reply for the differences between OnAfterGetRecord & OnAfterGetCurrentRecord ?

    Regards
    1 Destination, Multiple Route
  • SavatageSavatage Member Posts: 7,142
    vyanku wrote:
    But I just want to show the Dr or CR .So that client can understand that Customer balance is DR or CR.
    Can't they just look at the "Balance" field and see if it's negative or positive?

    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:
  • SavatageSavatage Member Posts: 7,142
    edisonl wrote:
    Hi Mr Vyanku,

    So did anyone post a reply for the differences between OnAfterGetRecord & OnAfterGetCurrentRecord ?

    Regards

    1.click on help
    2.View The C/side Reference guide
    3.click on Index tab
    4.Scroll to onafter....
Sign In or Register to comment.