How to Validate a field while opening a page.

Dileepa_BDileepa_B Member Posts: 9
Hello Everyone,

How to validate a field while opening a page.

For example: System must call Validate of "Direct Unit Cost" field while opening Requisition Worksheet page. I tried Validate function in OnAfterGetRecord and OnAfterGetCurrRecord. it didn't work out.
Dileepa B,
Microsoft Dynamics NAV Techno-Functional Consultant.

Answers

  • KishormKishorm Member Posts: 921
    If you want to do something when a page opens then you need to use the OnPageOpen trigger
  • skullaskulla Member Posts: 140
    Firstly why do you want to validate while opening the page, do you have a code which you want to execute if so where did you add that code on table or on page of that field validate trigger.
  • Dileepa_BDileepa_B Member Posts: 9
    Yes i want to execute in OnAfterGetRecord trigger page, but when i do it shows error.
    Dileepa B,
    Microsoft Dynamics NAV Techno-Functional Consultant.
  • KishormKishorm Member Posts: 921
    You can't make database changes in the OnAfterGetRecord trigger
  • Dileepa_BDileepa_B Member Posts: 9
    Is there any other way to Validate or update the field when open page?
    Dileepa B,
    Microsoft Dynamics NAV Techno-Functional Consultant.
  • KishormKishorm Member Posts: 921
    If you want to do it when the page opens then use the OnPageOpen() trigger
  • Dileepa_BDileepa_B Member Posts: 9
    Yes i tried the same, still same error.


    A transaction must be started before changes can be made to the database.

    Page Edit - Req. Worksheet must close.
    Dileepa B,
    Microsoft Dynamics NAV Techno-Functional Consultant.
  • KishormKishorm Member Posts: 921
    I've just tested it and databases changes in the OnPageOpen() trigger work fine for me.

    Are you sure you have put the code in OnPageOpen() and not in OnInit() for example?
  • Dileepa_BDileepa_B Member Posts: 9
    Yep I am sure.
    Dileepa B,
    Microsoft Dynamics NAV Techno-Functional Consultant.
  • KishormKishorm Member Posts: 921
    Try removing all code from all your page triggers and then running the page to make sure it works OK and then add code to the OnPageOpen trigger and see if that works.
  • Dileepa_BDileepa_B Member Posts: 9
    Thanks for your help but if i call Validate function from OnOpenPage system does not any validation because system doesn't fetch any record while opening page. Hence its of no use.
    Dileepa B,
    Microsoft Dynamics NAV Techno-Functional Consultant.
Sign In or Register to comment.