Options

Preventing from closing the page if a field isn't filled

poppinspoppins Member Posts: 647
edited 2015-04-07 in NAV Three Tier
Hi everyone,

I have a list page with several columns and an OK button.
I need to do the following: If column A is not filled by the user then he shouldn't be able to close the apge.
Here is the code I've written so far:
IF PAGE.RUNMODAL(PageX,RecX) = ACTION::LookupOK THEN BEGIN
//SOME CODE HERE that 
 IF (fieldXXX= TRUE) THEN ERROR(TextXX);
//SOME OTHER CODE HERE
END;
The problem with that code is that the user is still able to close the page and after that the error message appears.
How can I correct that to get the behaviour I want?

Thanks in advance :mrgreen:

Comments

  • Options
    vytjakvytjak Member Posts: 36
    Hi there,

    The problem lies in the fact that you are checking the fields after the Page.RUNMODAL() call. At that moment, the page is already closed.

    You should put your validation checks on the page itself in the "OnQueryClosePage" trigger and return false, if something needs to be corrected by the user. I.e.:
    OnQueryClosePage(CloseAction : Action None) : Boolean
    
    IF (fieldXXX=TRUE) THEN BEGIN
      MESSAGE(TextXX);
      EXIT(FALSE):
    END
    
    Vytenis Jakas
    B3 Technologies - Making Technology Serve the People
Sign In or Register to comment.