Can you exit OnInsert without actually inserting?

pberb
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.
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.
0
Comments
-
The OnInsert trigger in the Table0
-
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.com0 -
What about condition before calling the .INSERT(True)?0
-
Use
ERROR('Error');
or without message promptERROR(' ');
This will rollback all, even task completed before .INSERT(TRUE);Regards,
Peter Ng0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions