Options

Detecting when the user changes from one record to another

xavigepexavigepe Member Posts: 185
Hi. Which event can I use to detect when the user has changed from one record (for example a contact record) to another. I need to make some validations then.

Thnx

Comments

  • Options
    kinekine Member Posts: 12,562
    The trigger OnAfterGetCurrRecord is called after Navision get new actual record... (you select one...)
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Options
    KowaKowa Member Posts: 918
    Since the user can create just one new record and then close the form you will have to make the validations in the OnCloseForm too.
    Kai Kowalewski
  • Options
    kinekine Member Posts: 12,562
    I have some questions - what you want to reach by this? Do you want check all changes after the user save the record? What you want to check?

    May be that your answer will clear the situation and the solution will be easy... :-)
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Options
    xavigepexavigepe Member Posts: 185
    In fact. I only want to warn the user that certain fields must be filled (in case they are not filled). And I must do it only with some records (not all).
    I'm using the OnNextRecord trigger but I have some problems because when I show a warning the form shows the next record instead of the record the warning refers to. It'a a little mesh.

    The code is like:


    OK := TRUE;

    IF Type = Type::Person THEN
    OK := ValidaDatosContacto; //This function returns False if some
    compulsory fields are missing and shows
    a warning

    IF OK THEN
    EXIT(NEXT(Steps));
  • Options
    kinekine Member Posts: 12,562
    I think that you can do it in OnModify of the table, check the values, and if there is problem, call Error with some info... (or you can add it into OnInsert too, but you must test it)
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Options
    DenSterDenSter Member Posts: 8,304
    Yes I would go for OnModify in the table as well, so that it works no matter what object you use to change records.
  • Options
    SavatageSavatage Member Posts: 7,142
Sign In or Register to comment.