Options

quantity validate trigger not firing when asked

wicwic Member Posts: 96
MBS-Navision 4.0
Table 37.
New field MyField.
Onvalidate of that field, I write:
validate(quantity,myfield * 33)

the OnValidate trigger of field QUANTITY is not fired. :shock:
The value in quanitty is correct. (but all prices, ... aren't)
What this:ü@*# :evil: ](*,)
#### Only one can survive ######

Answers

  • Options
    itspeteritspeter Member Posts: 105
    I think you meant to code like below: -
    EVALUATE(quantity,myfield * 33);
    
    Regards,
    Peter Ng
  • Options
    wicwic Member Posts: 96
    no nope. I want to run the OnValidate trigger of the field quantity.
    This is trivial code that suddenly doesn't work anymore?!? Or something special happens to the quantity field of T37.
    The myField is a decimal.
    I want to validate the entered value (in myField) in the field Quantity with a sepcific mathematical formula
    #### Only one can survive ######
  • Options
    itspeteritspeter Member Posts: 105
    wic wrote:
    Onvalidate of that field, I write:
    validate(quantity,myfield * 33)

    You mentioned you wrote the command in the OnValidate Field. The validate command is to call OnValidate, which mean your command calling itself.

    To trigger this onvalidate, it should like below: -
    Rec.validate(quantity,myfield * 33)
    

    It should be calling outside the trigger, and not inside.
    Regards,
    Peter Ng
  • Options
    Marije_BrummelMarije_Brummel Member, Moderators Design Patterns Posts: 4,262
    I am sure you have but you did not mention it:

    Have you used the debugger to check what happens?
  • Options
    DenSterDenSter Member Posts: 8,304
    Have you tried creating a local decimal variable, and doing the calculation on it, like this:
    MyDecimal := MyField * 33;
    VALIDATE(Quantity,MyDecimal);
    
  • Options
    Iqbal_FebrianoIqbal_Febriano Member Posts: 66
    I belive the Quantity- OnValidate trigger is already fired. Just check it using debugger or simply put a message in it. If the price, etc doesn't change, I think it's because another reason, try to use debugger to find it out.
    Be fast, be straight, be quiet
  • Options
    wicwic Member Posts: 96
    thanx all. :-k
    The debugger goes through OnValidate of quantity but doesn't execute the same code as if I enter the qty directly in that field.

    Example:
    Table 37
    MyField (decimal)
    OnValidate()
    // WIC adapt qty
    validate(quantity,MyField * .03)


    Quantity
    OnValidate()
    "all standard code"

    On the sales order line:
    If I enter 100 in quantity: price is 200 (unit price = 2) (OK)
    MyField Quantity Price
    100 200

    if I enter 100 in MyField quantity is 3, price is still 200 should be 6 (NOK)
    MyField Quantity Price
    100 3 200

    if I go on quantity and validate the field, price is updated to 6 (OK)!!
    MyField Quantity Price
    100 3 6

    What's wrong? #-o
    #### Only one can survive ######
  • Options
    Marije_BrummelMarije_Brummel Member, Moderators Design Patterns Posts: 4,262
    I've performed a small test and noticed the same thing.

    In Table 37, some functions repspond to the field you are in. This is triggerd by the CurrFieldNo

    You should investigate what functions are called and somewhere add your field to some statement.

    You can use code coverage or the debugger to investigate what happens.
  • Options
    wicwic Member Posts: 96
    EUREKA!! =D> I found the problem.!!

    The function UpdateUnitPrice analyze the callingField with the currentField.
    The currentField in my case is MyField and NOT quantity! so he doesn't execute the unit price calc.
    What a complicated case for just a price update.
    :shock:
    That's all folk's. Thanx for your help.
    #### Only one can survive ######
  • Options
    Marije_BrummelMarije_Brummel Member, Moderators Design Patterns Posts: 4,262
    Congratulations. :D

    Yes, Navision is not as simple as it once was anymore :(

    Remember the [SOLVED] thing in the subject.
  • Options
    wakestarwakestar Member Posts: 207
    I would make a brakpoint at UpdateUnitPrice and
    > :shock:
    oops, too late :whistle:
Sign In or Register to comment.