Skip to content

Commit

Permalink
Import/Export data in Excel format
Browse files Browse the repository at this point in the history
Do not validate fields if it's not required upon import
Validation order fixed, for now, validation occurred with a new value to handle possible Rec-xRec inconsistency
Compile project with 12.2 runtime for older versions of BC
  • Loading branch information
Drakonian committed Aug 5, 2024
1 parent aedf5d8 commit 7db5437
Show file tree
Hide file tree
Showing 10 changed files with 400 additions and 86 deletions.
383 changes: 322 additions & 61 deletions Codeunits/Cod81001.DETDataEditorMgt.al

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions Enums/Enum81002.DETFileFormat.al
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
enum 81002 "DET File Format"
{
Extensible = true;

value(0; JSON)
{
Caption = 'JSON';
}
value(1; Excel)
{
Caption = 'Excel';
}
}
28 changes: 14 additions & 14 deletions Pages/Pag81000.DETDataEditorBuffer.al
Original file line number Diff line number Diff line change
Expand Up @@ -6623,7 +6623,7 @@ page 81000 "DET Data Editor Buffer"
SelectFields.GetRecord(TempDETField);
RecRefDuplicate := RecRef.Duplicate();
NewFieldRef := RecRefDuplicate.Field(TempDETField."Field Id");
if not DataEditorMgt.GetNewColumnValue(RecRef, NewFieldRef, Rec."Source Record ID", TempNameValueBuffer) then
if not DataEditorMgt.GetNewColumnValue(RecRef, NewFieldRef, Rec."Source Record ID", TempNameValueBuffer, not WithoutValidate) then
exit;
if not Confirm(ColumnUpdateConfirmLbl, false, TempDETField.Name, Rec.Count(), RecRef.Name()) then
exit;
Expand All @@ -6633,9 +6633,10 @@ page 81000 "DET Data Editor Buffer"
xRecRef := RecRef.Duplicate();
FieldRefVar := RecRef.Field(TempDETField."Field Id");
xFieldRefVar := xRecRef.Field(TempDETField."Field Id");
FieldRefVar.Value(NewFieldRef.Value());
if not WithoutValidate then
FieldRefVar.Validate();
if WithoutValidate then
FieldRefVar.Value(NewFieldRef.Value())
else
FieldRefVar.Validate(NewFieldRef.Value());
RecRef.Modify(not WithoutValidate);
if IsLogEnabled then
DataEditorMgt.LogModify(RecRef.Number(), FieldRefVar.Number(), RecRef.RecordId(), xFieldRefVar,
Expand Down Expand Up @@ -6701,9 +6702,10 @@ page 81000 "DET Data Editor Buffer"
CopyFromFieldRef.CalcField();
CopyToFieldRef := RecRef.Field(CopyToFieldNo);
xCopyToFieldRef := xRecRef.Field(CopyToFieldNo);
CopyToFieldRef.Value(CopyFromFieldRef.Value());
if not WithoutValidate then
CopyToFieldRef.Validate();
if WithoutValidate then
CopyToFieldRef.Value(CopyFromFieldRef.Value())
else
CopyToFieldRef.Validate(CopyFromFieldRef.Value());
RecRef.Modify(not WithoutValidate);
if IsLogEnabled then
DataEditorMgt.LogModify(RecRef.Number(), CopyToFieldRef.Number(), RecRef.RecordId(), xCopyToFieldRef,
Expand Down Expand Up @@ -6887,10 +6889,10 @@ page 81000 "DET Data Editor Buffer"
DataEditorMgt.LogRename(RecRef.Number(), FieldRefVar.Number(), RecRef.RecordId(), xFieldRefVar, FieldRefVar, true);
exit;
end;

FieldRefVar.Value(DataEditorMgt.TextValueAsVariant(FieldRefVar.Type(), NewValue));
if not WithoutValidate then
FieldRefVar.Validate();
if WithoutValidate then
FieldRefVar.Value(DataEditorMgt.TextValueAsVariant(FieldRefVar.Type(), NewValue))
else
FieldRefVar.Validate(DataEditorMgt.TextValueAsVariant(FieldRefVar.Type(), NewValue));
RecRef.Modify(not WithoutValidate);

if IsLogEnabled then
Expand All @@ -6915,11 +6917,9 @@ page 81000 "DET Data Editor Buffer"
FieldRefVar := RecRef.Field(OriginalFieldNo);
xFieldRefVar := xRecRef.Field(OriginalFieldNo);

if not DataEditorMgt.GetNewColumnValue(RecRef, FieldRefVar, Rec."Source Record ID", TempNameValueBuffer) then
if not DataEditorMgt.GetNewColumnValue(RecRef, FieldRefVar, Rec."Source Record ID", TempNameValueBuffer, not WithoutValidate) then
exit;

if not WithoutValidate then
FieldRefVar.Validate();
RecRef.Modify(not WithoutValidate);

if FieldRefVar.Type() = FieldRefVar.Type::Option then
Expand Down
20 changes: 11 additions & 9 deletions Pages/Pag81007.DETFindandReplace.al
Original file line number Diff line number Diff line change
Expand Up @@ -200,10 +200,11 @@ page 81007 "DET Find and Replace"
if Replace and Rec."Is Editable" then begin
FieldRefToModify := RecRef.Field(Rec."Field Number");
xFieldRefToModify := xRecRef.Field(Rec."Field Number");
FieldRefToModify.Value(ReplaceWith);
if GlobalWithoutValidate then
FieldRefToModify.Value(ReplaceWith)
else
FieldRefToModify.Validate(ReplaceWith);
Rec."Field Value" := CopyStr(ReplaceWith, 1, MaxStrLen(Rec."Field Value"));
if not GlobalWithoutValidate then
FieldRefToModify.Validate();
ReplacedCounter += 1;
if IsLogEnabled then
DataEditorMgt.LogModify(RecRef.Number(), FieldRefToModify.Number(), RecRef.RecordId(), xFieldRefToModify,
Expand Down Expand Up @@ -256,14 +257,15 @@ page 81007 "DET Find and Replace"
FieldRefVar := RecRef.Field(FieldNo);
xFieldRefVar := xRecRef.Field(FieldNo);

if not IsDrillDown then
FieldRefVar.Value(NewValue)
else
if not DataEditorMgt.GetNewColumnValue(RecRef, FieldRefVar, Rec."Record Id", TempNameValueBuffer) then
if not IsDrillDown then begin
if GlobalWithoutValidate then
FieldRefVar.Value(NewValue)
else
FieldRefVar.Validate(NewValue);
end else
if not DataEditorMgt.GetNewColumnValue(RecRef, FieldRefVar, Rec."Record Id", TempNameValueBuffer, not GlobalWithoutValidate) then
exit;

if not GlobalWithoutValidate then
FieldRefVar.Validate();
RecRef.Modify(not GlobalWithoutValidate);

if FieldRefVar.Type() = FieldRefVar.Type::Option then
Expand Down
18 changes: 18 additions & 0 deletions Pages/Pag81011.DETImportExportDialog.al
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,39 @@ page 81011 "DET Import/Export Dialog"
{
group(General)
{
field(FileFormat; FileFormat)
{
ApplicationArea = All;
Caption = 'File Format';
ToolTip = 'File Format';
}
field(ImportOnFind; ImportOnFind)
{
ApplicationArea = All;
Caption = 'Import On Find';
ToolTip = 'Action to do when imported record is already exist in database';
Visible = IsImport;
}
}
}
}
procedure SetIsImport(inIsImport: Boolean)
begin
IsImport := inIsImport;
end;

procedure GetImportOnFind(): Enum "DET Import On Find"
begin
exit(ImportOnFind);
end;

procedure GetFileFormat(): Enum "DET File Format"
begin
exit(FileFormat);
end;

var
IsImport: Boolean;
ImportOnFind: Enum "DET Import On Find";
FileFormat: Enum "DET File Format";
}
20 changes: 20 additions & 0 deletions Translations/Data Editor Tool.g.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -4683,6 +4683,16 @@
<note from="Developer" annotates="general" priority="2"></note>
<note from="Xliff Generator" annotates="general" priority="3">Page DET Import/Export Dialog - Property Caption</note>
</trans-unit>
<trans-unit id="Page 278861421 - Control 4072933583 - Property 1295455071" size-unit="char" translate="yes" xml:space="preserve">
<source>File Format</source>
<note from="Developer" annotates="general" priority="2"></note>
<note from="Xliff Generator" annotates="general" priority="3">Page DET Import/Export Dialog - Control FileFormat - Property ToolTip</note>
</trans-unit>
<trans-unit id="Page 278861421 - Control 4072933583 - Property 2879900210" size-unit="char" translate="yes" xml:space="preserve">
<source>File Format</source>
<note from="Developer" annotates="general" priority="2"></note>
<note from="Xliff Generator" annotates="general" priority="3">Page DET Import/Export Dialog - Control FileFormat - Property Caption</note>
</trans-unit>
<trans-unit id="Page 278861421 - Control 1262534867 - Property 1295455071" size-unit="char" translate="yes" xml:space="preserve">
<source>Action to do when imported record is already exist in database</source>
<note from="Developer" annotates="general" priority="2"></note>
Expand Down Expand Up @@ -4953,6 +4963,16 @@
<note from="Developer" annotates="general" priority="2"></note>
<note from="Xliff Generator" annotates="general" priority="3">Page DET Select Fields - Action Set Included - Property Caption</note>
</trans-unit>
<trans-unit id="Enum 2951046972 - EnumValue 1819335129 - Property 2879900210" size-unit="char" translate="yes" xml:space="preserve">
<source>Excel</source>
<note from="Developer" annotates="general" priority="2"></note>
<note from="Xliff Generator" annotates="general" priority="3">Enum DET File Format - EnumValue Excel - Property Caption</note>
</trans-unit>
<trans-unit id="Enum 2951046972 - EnumValue 2264048100 - Property 2879900210" size-unit="char" translate="yes" xml:space="preserve">
<source>JSON</source>
<note from="Developer" annotates="general" priority="2"></note>
<note from="Xliff Generator" annotates="general" priority="3">Enum DET File Format - EnumValue JSON - Property Caption</note>
</trans-unit>
<trans-unit id="Enum 2422027088 - EnumValue 2248886284 - Property 2879900210" size-unit="char" translate="yes" xml:space="preserve">
<source>Error</source>
<note from="Developer" annotates="general" priority="2"></note>
Expand Down
Binary file removed Volodymyr Dvernytskyi_Data Editor Tool_3.0.0.0.app
Binary file not shown.
Binary file not shown.
Binary file modified Volodymyr Dvernytskyi_Data Editor Tool_Latest.app
Binary file not shown.
4 changes: 2 additions & 2 deletions app.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"id": "e28d62da-ceb0-46e7-9e06-774bc46f4bac",
"name": "Data Editor Tool",
"publisher": "Volodymyr Dvernytskyi",
"version": "3.0.0.0",
"version": "3.0.0.2",
"brief": "https://vld-nav.com/",
"description": "https://vld-nav.com/",
"privacyStatement": "https://vld-nav.com/",
Expand All @@ -21,7 +21,7 @@
}
],
"contextSensitiveHelpUrl": "https://vld-nav.com/",
"runtime": "13.0",
"runtime": "12.2",
"features": ["TranslationFile"],
"resourceExposurePolicy":
{
Expand Down

0 comments on commit 7db5437

Please sign in to comment.