Global variable in onDelete trigger

weneed
Member Posts: 82
I need to delete a set of record in a table (Table1) applying filter. For each record in this table there may be other records in a secondary table (Table2).
In onDelete trigger there is code to cascade delete all record related in Table2. But in this code there is a confirm to ask user every time a record was deleted.
I want use trigger to delete related record but i need skip confirm. So I've create a global variable, hideConfirm, to skip this confirm and a procedure to set this variable.
This is code:
trigger OnDelete()
begin
if not HideConfirm then
if not CONFIRM(QstDeleteSchema, FALSE) then
exit;
Table2.SETRANGE(FieldFilter, FieldFilterValue);
Table2.DELETEALL;
end;
procedure SetHideConfirm(parHideConfirm: Boolean)
var
begin
HideConfirm := parHideConfirm
end;
This was main code that execute
RecordsetTable.SetHideConfirm(true);
RecordsetTable.DELETEALL(TRUE);
But when execute OnDelete trigger HideConfirm global variable was false...
Why?
In onDelete trigger there is code to cascade delete all record related in Table2. But in this code there is a confirm to ask user every time a record was deleted.
I want use trigger to delete related record but i need skip confirm. So I've create a global variable, hideConfirm, to skip this confirm and a procedure to set this variable.
This is code:
trigger OnDelete()
begin
if not HideConfirm then
if not CONFIRM(QstDeleteSchema, FALSE) then
exit;
Table2.SETRANGE(FieldFilter, FieldFilterValue);
Table2.DELETEALL;
end;
procedure SetHideConfirm(parHideConfirm: Boolean)
var
begin
HideConfirm := parHideConfirm
end;
This was main code that execute
RecordsetTable.SetHideConfirm(true);
RecordsetTable.DELETEALL(TRUE);
But when execute OnDelete trigger HideConfirm global variable was false...
Why?
0
Answers
-
Try using DELETE(TRUE) looping through the record set yourself. If the Trigger is to be used (requested by using DELETE(TRUE)) then the system needs to delete the records one by one anyway.0
-
But question is: why variable HideConfirm not save value if RecordsetTable instance is same?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