OnValidate trigger is executed two times on Page

Ravi_Prakash_GoyalRavi_Prakash_Goyal Member Posts: 72
edited 2013-07-01 in NAV Three Tier
Hi,

I am getting an strange error on Page. I create a Boolean variable 'testbool' and add it as field on page and write following code on OnValidate trigger of this field

testbool - OnValidate()
testbool := NOT testbool;
MESSAGE('test01');

Surprisingly, the OnValidate trigger is executing two times when I click on Boolean value i.e. above message appears two times. It this a bug in the product? Please help I need to fix it for my current upgrade project.

I am using NAV2013 (Build 7.00.34587). I can see there is a similar Hotfix released (KB 2797787 in Build 7.0.34194) by Microsoft but it does not resolve my issue.

Regards,
Ravi Prakash Goyal

Comments

  • Marije_BrummelMarije_Brummel Member, Moderators Design Patterns Posts: 4,262
    Yes, it's a bug. It should be fixed in some hf. I don't know the number.
  • MMVMMV Member Posts: 99
    Ravi, but what you are trying to achieve by this code?
  • Ravi_Prakash_GoyalRavi_Prakash_Goyal Member Posts: 72
    Yes, it's a bug. It should be fixed in some hf. I don't know the number.
    I checked this in the latest release NAV2013 FP1 (build 7.0.34797.0) also, this is not fixed.
    MMV wrote:
    Ravi, but what you are trying to achieve by this code?
    Here is my actual code. The objective here is to reset the Boolean variable 'ScannedIsDefaulBarcode' to its original state if user does not confirm the action. If I don't do that, system will update the changed value to the variable, which is not correct.

    Name ConstValue
    Text007 Are you sure you want to set Default Barcode field to %1 for the scanned barcode %2.

    ScannedIsDefaulBarcode - OnValidate()
    IF CONFIRM(STRSUBSTNO(Text007,ScannedIsDefaulBarcode,ItemCross."Cross-Reference No.")) THEN BEGIN
    IF ScannedIsDefaulBarcode THEN BEGIN
    ......
    ......
    END;
    END ELSE BEGIN
    ScannedIsDefaulBarcode := NOT ScannedIsDefaulBarcode;
    EXIT;
    END
Sign In or Register to comment.