Stop Delete Process in onDelete() Trigger

elTorito
Member Posts: 191
Hi,
I One Table in the onDelete Trigger i Have Code that checks
if a part of the record that i want to delete have a relation to a record in another table, if they are are relation, i would stop the delete Process.
But i don't know who.
Here my Code that not works:
Thanks
PS: I think that the EXIT Command ist wrong for this way ?
I One Table in the onDelete Trigger i Have Code that checks
if a part of the record that i want to delete have a relation to a record in another table, if they are are relation, i would stop the delete Process.
But i don't know who.
Here my Code that not works:
myRecord.RESET; myRecord.SETFILTER("myField",'myData'); IF myRecord.FIND('-') THEN BEGIN MESSAGE('Don't Delete Them'); EXIT; END ELSE BEGIN MESSAGE('ok, must delete'); END;
Thanks
PS: I think that the EXIT Command ist wrong for this way ?
(Oo)=*=(oO)
0
Comments
-
I'm Stupid ...
It Must be ERROR and Not MESSAGE :P
So it's right:myRecord.RESET; myRecord.SETFILTER("myField",'myData'); IF myRecord.FIND('-') THEN BEGIN ERROR('Can't Delete Them'); END;
(Oo)=*=(oO)0 -
You must write EXIT(FALSE).DDE functions in Navision0
-
s_vahagn wrote:You must write EXIT(FALSE).
If i put EXIT(FALSE) it say may that :
"A variable was expected"
If i put only EXIT it's okay but does not exit.
No i have it so, an it works:myRecord.RESET; myRecord.SETFILTER("myField",'=%1', "myVarForField"); IF myRecord.FIND('-') THEN BEGIN IF CONFIRM('Would you delete it?') = FALSE THEN BEGIN ERROR('Not deleted'); END; END;
I Think that an EXIT an this position is more nice than the error message because, so the user must first press the confirm and second press the message thats say him that was not deleted, but if i put an EXIT there where ist the ERROR now, it delete me the recordand EXIT(FALSE) would expected a variable ?
Thanks.(Oo)=*=(oO)0 -
Hi,
The "Variable Expected" is that the OnDelete trigger by definition has no return value.
You can useERROR('')
which stops the transaction and doesn't displays any error.0
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