-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathReport 50199 DataDeletionReport.al
169 lines (155 loc) · 6.41 KB
/
Report 50199 DataDeletionReport.al
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
report 50199 DataDeletionTool
{
UsageCategory = Administration;
ApplicationArea = All;
ProcessingOnly = true;
Caption = 'Filtered Data Deletion';
Permissions = TableData "17" = IMD, Tabledata "36" = IMD, Tabledata "37" = IMD, Tabledata "38" = IMD, Tabledata "39" = IMD, Tabledata "81" = IMD, Tabledata "21" = IMD, Tabledata "25" = IMD, Tabledata "32" = IMD, Tabledata "110" = IMD, TableData "111" = IMD, TableData "112" = IMD, TableData "113" = IMD, TableData "114" = IMD, TableData "115" = IMD, TableData "120" = IMD, Tabledata "121" = IMD, Tabledata "122" = IMD, Tabledata "123" = IMD, Tabledata "124" = IMD, Tabledata "125" = IMD, Tabledata "169" = IMD, Tabledata "379" = IMD, Tabledata "380" = IMD, Tabledata "271" = IMD, Tabledata "5802" = IMD, tabledata "6650" = IMD, tabledata "6660" = IMD;
dataset
{
dataitem(DataItemName; "Company Information")
{
}
}
requestpage
{
layout
{
area(Content)
{
group(GroupName)
{
Caption = 'Filters';
field(TableNo; TableNo)
{
ApplicationArea = All;
Caption = 'Table No.';
trigger OnDrillDown()
var
RecAllObjects: Record AllObjWithCaption;
PageAllObjectst: Page "All Objects with Caption";
begin
Clear(RecAllObjects);
Clear(PageAllObjectst);
RecAllObjects.SetRange("Object Type", RecAllObjects."Object Type"::Table);
IF RecAllObjects.FindSet() then begin
PageAllObjectst.LookupMode := true;
PageAllObjectst.SetTableView(RecAllObjects);
PageAllObjectst.SetRecord(RecAllObjects);
IF PageAllObjectst.RunModal() = Action::LookupOK then begin
PageAllObjectst.GetRecord(RecAllObjects);
TableNo := RecAllObjects."Object ID";
TableName := RecAllObjects."Object Name";
end;
end;
end;
trigger OnValidate()
var
RecAllObjects: Record AllObjWithCaption;
begin
Clear(RecAllObjects);
RecAllObjects.Reset();
RecAllObjects.SetRange("Object ID", TableNo);
IF RecAllObjects.FindFirst() then
TableName := RecAllObjects."Object Name";
end;
}
field(TableName; TableName)
{
ApplicationArea = All;
Editable = false;
Caption = 'Table Name';
}
field(PrimaryKeyFilter1; PrimaryKeyFilter1)
{
ApplicationArea = All;
Caption = 'Primary Key';
ToolTip = 'Primary key for the record Click on |...| (Assist Edit) to browse the table';
trigger OnAssistEdit()
var
BrowseLink: Text;
begin
BrowseLink := 'https://businesscentral.dynamics.com/?table=' + FORMAT(TableNo);
Hyperlink(BrowseLink);
end;
}
field(PrimaryKeyFilter2; PrimaryKeyFilter2)
{
ApplicationArea = All;
Caption = 'Key 2';
ToolTip = 'Second Composite Key for the record';
}
field(PrimaryKeyFilter3; PrimaryKeyFilter3)
{
ApplicationArea = All;
Caption = 'Key 3';
ToolTip = 'Third Composite Key for the record';
}
}
}
}
}
var
TableNo: Integer;
TableName: Text;
PrimaryKeyFilter1: Text;
PrimaryKeyFilter2: Text;
PrimaryKeyFilter3: Text;
RecRef: RecordRef;
FldRef: FieldRef;
KeyRefer: KeyRef;
KeyIndex: Integer;
trigger OnPostReport()
begin
//FetchRecord(37, 'Order', 'SO10041', '2000');
if TableNo = 0 then
Error('Table No. value cannot be blank');
if PrimaryKeyFilter1 = '' then
Error('Primary Key value cannot be blank');
FetchRecord(TableNo, PrimaryKeyFilter1, PrimaryKeyFilter2, PrimaryKeyFilter3);
end;
local procedure FetchRecord(TableNo: Integer; Pk1: Text; Pk2: Text; Pk3: Text);
var
i: Integer;
PK: array[3] of Text;
DeleteConfirm: Text;
begin
PK[1] := Pk1;
PK[2] := Pk2;
PK[3] := Pk3;
DeleteConfirm := 'Do you want to delete the following record? \';
Clear(RecRef);
Clear(FldRef);
Clear(KeyRefer);
RecRef.Open(TableNo);
RecRef.SetRecFilter();
KeyRefer := RecRef.KeyIndex(1);
for i := 1 TO KeyRefer.FieldCount() do begin
FldRef := KeyRefer.FieldIndex(i);
IF PK[i] <> '' then
FldRef.SetFilter(PK[i]);
end;
IF RecRef.FindSet() then begin
DeleteConfirm := DeleteConfirm + Format(RecRef);
repeat
IF RecRef.Count = 1 then begin
IF Confirm(DeleteConfirm) then begin
RecRef.Delete();
Message('Record is deleted!')
end;
end
/*else begin
IF Confirm('Do you want to bulk delete all the records?') then begin
RecRef.DeleteAll();
Message('Records are deleted!');
end;
end;*/
until RecRef.Next() = 0;
end;
RecRef.Close();
end;
procedure GetTableNo(TableNumber: Integer)
begin
TableNo := TableNumber;
end;
}