Can you exit OnInsert without actually inserting?

pberbpberb Member Posts: 31
Is there a way to exit out of the OnInsert trigger without inserting a record and returning an error condition? What I'd like to do, is that if one of the field's in the record to be inserted is blank, then don't insert the record (ie. just ignore inserting it). I don't want to use ERROR('') because this returns an error condition that prevents further data entry on a form.

If this can't be done in the OnInsert trigger, then perhaps someone can suggest a different solution?

I have a list form with variable fields in a header section that I'm using as filters for fields on the form. My problem is that after entering each field filter, a new blank record is created (that I don't want). This occurs because I have in each fields' OnAfterValidate trigger:

SETFILTER("<fieldname>",<field>);
CurrForm.UPDATE(FALSE);

After entering a field, the form gets re-filtered according to the value entered, but also a new blank record gets inserted after the CurrForm.UPDATE(FALSE) statement. If I remove the CurrForm.UPDATE statement, blank records don't get inserted, but then the form doesn't update with the filtered field, either.

Comments

  • pberbpberb Member Posts: 31
    The OnInsert trigger in the Table
  • andreofandreof Member Posts: 133
    if you use exit(false) in the trigger OnInsertRecord of the form, the record will not be inserted.
    Andre Fidalgo
    My world: Dynamics NAV,SQL and .NET

    CEO at Solving Dynamics
    http://www.solvingdynamics.com
  • kinekine Member Posts: 12,562
    What about condition before calling the .INSERT(True)?
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • itspeteritspeter Member Posts: 105
    Use
    ERROR('Error');
    

    or without message prompt
    ERROR(' ');
    

    This will rollback all, even task completed before .INSERT(TRUE);
    Regards,
    Peter Ng
Sign In or Register to comment.