diff --git a/Codeunits/Cod81001.DETDataEditorMgt.al b/Codeunits/Cod81001.DETDataEditorMgt.al index 175a156..b0a8f1a 100644 --- a/Codeunits/Cod81001.DETDataEditorMgt.al +++ b/Codeunits/Cod81001.DETDataEditorMgt.al @@ -15,7 +15,7 @@ codeunit 81001 "DET Data Editor Mgt." tabledata "Service Invoice Header" = RMID, TableData "Service Cr.Memo Header" = RMID, TableData "Issued Reminder Header" = RMID, TableData "Issued Fin. Charge Memo Header" = RMID, tabledata "G/L Entry - VAT Entry Link" = RMID; - procedure GetNewColumnValue(var RecRef: RecordRef; var FieldRefVar: FieldRef; var SourceRecordId: RecordId; var TempNameValueBuffer: Record "Name/Value Buffer" temporary): Boolean + procedure GetNewColumnValue(var RecRef: RecordRef; var FieldRefVar: FieldRef; var SourceRecordId: RecordId; var TempNameValueBuffer: Record "Name/Value Buffer" temporary; WithValidate: Boolean): Boolean var FieldRec: Record Field; DataEditorSetup: Record "DET Data Editor Setup"; @@ -64,16 +64,25 @@ codeunit 81001 "DET Data Editor Mgt." ResultVariant := FieldNo; end; RenamePKField(RecRef, FieldRefVar, SourceRecordId, ResultVariant); - if FieldRefVar.Type() = FieldRefVar.Type::Option then - FieldRefVar.Value(TempNameValueBuffer.Value) - else - FieldRefVar.Value(format(ResultVariant)); + if FieldRefVar.Type() = FieldRefVar.Type::Option then begin + if WithValidate then + FieldRefVar.Validate(TempNameValueBuffer.Value) + else + FieldRefVar.Value(TempNameValueBuffer.Value); + end else + if WithValidate then + FieldRefVar.Validate(format(ResultVariant)) + else + FieldRefVar.Value(format(ResultVariant)); if DataEditorSetup.Get() then if DataEditorSetup."Enable Data Editor Log" then LogRename(RecRef.Number(), FieldRefVar.Number(), RecRef.RecordId(), xFieldRefVar, FieldRefVar, true); exit(true); end; - FieldRefVar.Value(ResultVariant); + if WithValidate then + FieldRefVar.Validate(ResultVariant) + else + FieldRefVar.Value(ResultVariant); exit(true); end; @@ -286,12 +295,142 @@ codeunit 81001 "DET Data Editor Mgt." var TempBlob: Codeunit "Temp Blob"; ImportExportDialog: Page "DET Import/Export Dialog"; + ImportOnFind: Enum "DET Import On Find"; + FileFormat: Enum "DET File Format"; + FileInStream: InStream; + FileFilter: Text; + begin + ImportExportDialog.Caption('Import Dialog'); + ImportExportDialog.SetIsImport(true); + if GuiAllowed() then + if not (ImportExportDialog.RunModal() in [Action::OK, Action::LookupOK]) then + exit; + ImportOnFind := ImportExportDialog.GetImportOnFind(); + FileFormat := ImportExportDialog.GetFileFormat(); + + case FileFormat of + FileFormat::JSON: + FileFilter := JSONFilterLbl; + FileFormat::Excel: + FileFilter := ExcelFilterLbl; + end; + + TempBlob.CreateInStream(FileInStream, TextEncoding::UTF8); + if not UploadIntoStream(FileFilter, FileInStream) then + exit; + + case FileFormat of + FileFormat::JSON: + ImportJSON(FileInStream, ImportOnFind, WithValidation); + FileFormat::Excel: + ImportExcel(FileInStream, ImportOnFind, WithValidation); + end; + end; + + local procedure ImportExcel(var FileInStream: InStream; ImportOnFind: Enum "DET Import On Find"; WithValidation: Boolean) + var + TempExcelBuffer: Record "Excel Buffer" temporary; + TempNameValueBuffer: Record "Name/Value Buffer" temporary; + RecRef: RecordRef; + xRecRef: RecordRef; + FieldRef: FieldRef; + CellValueInStream: InStream; + TableNo: Integer; + ColumnFieldNoDict: Dictionary of [Integer, Integer]; + Skipped, Inserted, Modified : Integer; + IsPKReady, IsRecordExist : Boolean; + ResultMsg: TextBuilder; + ValueAsTxt: Text; + ErrorText: Text; + begin + TempExcelBuffer.GetSheetsNameListFromStream(FileInStream, TempNameValueBuffer); + + TempNameValueBuffer.SetRange(Value, 'Data'); + TempNameValueBuffer.FindFirst(); + + ClearLastError(); + ErrorText := TempExcelBuffer.OpenBookStream(FileInStream, TempNameValueBuffer.Value); + if ErrorText <> '' then + Error(ErrorText); + + TempExcelBuffer.ReadSheetContinous('Data', true); + + Evaluate(TableNo, TempExcelBuffer.GetValueByCellName('B1')); + + RecRef.Open(TableNo); + RecRef.ReadIsolation := RecRef.ReadIsolation::ReadCommitted; + + xRecRef.Open(TableNo); + xRecRef.ReadIsolation := xRecRef.ReadIsolation::ReadCommitted; + + TempExcelBuffer.SetCurrentKey("Row No."); + if TempExcelBuffer.FindSet() then begin + repeat + TempExcelBuffer.SetRange("Row No.", TempExcelBuffer."Row No."); + Clear(IsPKReady); + Clear(IsRecordExist); + + RecRef.Init(); + + repeat + Clear(ValueAsTxt); + if TempExcelBuffer."Cell Value as Blob".HasValue() then begin + TempExcelBuffer.CalcFields("Cell Value as Blob"); + TempExcelBuffer."Cell Value as Blob".CreateInStream(CellValueInStream, TextEncoding::Windows); + CellValueInStream.ReadText(ValueAsTxt); + end else + ValueAsTxt := TempExcelBuffer."Cell Value as Text"; + + case true of + TempExcelBuffer."Row No." = 3: + begin + FieldRef := RecRef.Field(GetFieldNoFromName(TableNo, ValueAsTxt)); + if FieldRef.Class() = FieldRef.Class() ::Normal then + ColumnFieldNoDict.Add(TempExcelBuffer."Column No.", FieldRef.Number()); + end; + + TempExcelBuffer."Row No." > 3: + if ColumnFieldNoDict.ContainsKey(TempExcelBuffer."Column No.") then begin + FieldRef := RecRef.Field(ColumnFieldNoDict.Get(TempExcelBuffer."Column No.")); + UpdateRecord(ValueAsTxt, RecRef, xRecRef, FieldRef, ImportOnFind, IsPKReady, IsRecordExist, WithValidation); + end; + end; + until TempExcelBuffer.Next() = 0; + + if TempExcelBuffer."Row No." > 3 then + SaveRecord(RecRef, ImportOnFind, WithValidation, IsRecordExist, Inserted, Skipped, Modified); + + TempExcelBuffer.SetRange("Row No."); + until TempExcelBuffer.Next() = 0; + + RecRef.Close(); + xRecRef.Close(); + end; + + ResultMsg.AppendLine(ImportFinishedLbl); + ResultMsg.AppendLine(StrSubstNo(InsertedLbl, Inserted)); + ResultMsg.AppendLine(StrSubstNo(ModifiedLbl, Modified)); + ResultMsg.AppendLine(StrSubstNo(SkippedLbl, Skipped)); + + if GuiAllowed() then + Message(ResultMsg.ToText()); + end; + + local procedure GetFieldNoFromName(TableNo: Integer; FieldName: Text): Integer + var + FieldRec: Record Field; + begin + FieldRec.SetRange(TableNo, TableNo); + FieldRec.SetRange(FieldName, FieldName); + FieldRec.FindFirst(); + exit(FieldRec."No."); + end; + + local procedure ImportJSON(var FileInStream: InStream; ImportOnFind: Enum "DET Import On Find"; WithValidation: Boolean) + var RecRef: RecordRef; xRecRef: RecordRef; FieldRef: FieldRef; - xFieldRef: FieldRef; - ImportOnFind: Enum "DET Import On Find"; - InStreamVar: InStream; JObject: JsonObject; JToken: JsonToken; JTokenField: JsonToken; @@ -304,16 +443,8 @@ codeunit 81001 "DET Data Editor Mgt." IsPKReady, IsRecordExist : Boolean; ResultMsg: TextBuilder; begin - ImportExportDialog.Caption('Import Dialog'); - if not (ImportExportDialog.RunModal() in [Action::OK, Action::LookupOK]) then - exit; - ImportOnFind := ImportExportDialog.GetImportOnFind(); + JObject.ReadFrom(FileInStream); - TempBlob.CreateInStream(InStreamVar, TextEncoding::UTF8); - if not UploadIntoStream(JSONFilterLbl, InStreamVar) then - exit; - - JObject.ReadFrom(InStreamVar); ListOfTables := JObject.Keys(); foreach TableNoAsTxt in ListOfTables do begin JObject.Get(TableNoAsTxt, JToken); @@ -329,6 +460,9 @@ codeunit 81001 "DET Data Editor Mgt." JArray := JToken.AsArray(); foreach JToken in JArray do begin + Clear(IsPKReady); + Clear(IsRecordExist); + RecRef.Init(); ListOfFields := JToken.AsObject().Keys(); @@ -337,49 +471,15 @@ codeunit 81001 "DET Data Editor Mgt." Evaluate(FieldNo, FieldNoAsTxt); FieldRef := RecRef.Field(FieldNo); - if not IsPKReady then - if not IsFieldIsPartOfPK(RecRef, FieldRef) then begin - IsRecordExist := xRecRef.Get(RecRef.RecordId()); - IsPKReady := true; - end; - - if IsRecordExist then - xFieldRef := xRecRef.Field(FieldNo); - - FieldRef.Value(TextValueAsVariant(FieldRef.Type, CopyStr(JTokenField.AsValue().AsText(), 1, 2048))); - if WithValidation then - FieldRef.Validate(); - - if IsRecordExist and (ImportOnFind = ImportOnFind::Modify) then - LogModify(RecRef.Number(), FieldNo, RecRef.RecordId(), xFieldRef, FieldRef, WithValidation); - end; - - case ImportOnFind of - ImportOnFind::Error: - begin - RecRef.Insert(WithValidation); - LogInsert(RecRef.Number(), RecRef.RecordId(), WithValidation); - Inserted += 1; - end; - ImportOnFind::Skip: - if RecRef.Insert(WithValidation) then begin - LogInsert(RecRef.Number(), RecRef.RecordId(), WithValidation); - Inserted += 1; - end else - Skipped += 1; - ImportOnFind::Modify: - if RecRef.Insert(WithValidation) then begin - LogInsert(RecRef.Number(), RecRef.RecordId(), WithValidation); - Inserted += 1; - end else begin - RecRef.Modify(WithValidation); - Modified += 1; - end; + UpdateRecord(JTokenField.AsValue().AsText(), RecRef, xRecRef, FieldRef, ImportOnFind, IsPKReady, IsRecordExist, WithValidation); end; + SaveRecord(RecRef, ImportOnFind, WithValidation, IsRecordExist, Inserted, Skipped, Modified); end; RecRef.Close(); + xRecRef.Close(); end; + ResultMsg.AppendLine(ImportFinishedLbl); ResultMsg.AppendLine(StrSubstNo(InsertedLbl, Inserted)); ResultMsg.AppendLine(StrSubstNo(ModifiedLbl, Modified)); @@ -389,19 +489,178 @@ codeunit 81001 "DET Data Editor Mgt." Message(ResultMsg.ToText()); end; + local procedure UpdateRecord(ValueAsTxt: Text; var RecRef: RecordRef; var xRecRef: RecordRef; var FieldRef: FieldRef; ImportOnFind: Enum "DET Import On Find"; var IsPKReady: Boolean; var IsRecordExist: Boolean; WithValidation: Boolean) + var + xFieldRef: FieldRef; + begin + if not IsPKReady then + if not IsFieldIsPartOfPK(RecRef, FieldRef) then begin + IsRecordExist := xRecRef.Get(RecRef.RecordId()); + IsPKReady := true; + end; + + if IsRecordExist and (ImportOnFind = ImportOnFind::Skip) then + exit; + + if IsRecordExist then + xFieldRef := xRecRef.Field(FieldRef.Number()); + + if WithValidation then + FieldRef.Validate(TextValueAsVariant(FieldRef.Type, CopyStr(ValueAsTxt, 1, 2048))) + else + FieldRef.Value(TextValueAsVariant(FieldRef.Type, CopyStr(ValueAsTxt, 1, 2048))); + + if IsRecordExist and (ImportOnFind = ImportOnFind::Modify) then + LogModify(RecRef.Number(), FieldRef.Number(), RecRef.RecordId(), xFieldRef, FieldRef, WithValidation); + end; + + local procedure SaveRecord(var RecRef: RecordRef; ImportOnFind: Enum "DET Import On Find"; WithValidation: Boolean; IsRecordExist: Boolean; var Inserted: Integer; var Skipped: Integer; var Modified: Integer) + begin + case ImportOnFind of + ImportOnFind::Error: + begin + RecRef.Insert(WithValidation); + LogInsert(RecRef.Number(), RecRef.RecordId(), WithValidation); + Inserted += 1; + end; + ImportOnFind::Skip: + if IsRecordExist then + Skipped += 1 + else begin + RecRef.Insert(WithValidation); + LogInsert(RecRef.Number(), RecRef.RecordId(), WithValidation); + Inserted += 1; + end; + ImportOnFind::Modify: + if IsRecordExist then begin + RecRef.Modify(WithValidation); + Modified += 1 + end else begin + RecRef.Insert(WithValidation); + LogInsert(RecRef.Number(), RecRef.RecordId(), WithValidation); + Inserted += 1; + end; + end; + end; + procedure ExportTable(var DataEditorBuffer: Record "DET Data Editor Buffer"; FieldIdsToExport: List of [Integer]) var + ImportExportDialog: Page "DET Import/Export Dialog"; + FileFormat: Enum "DET File Format"; + begin + if DataEditorBuffer.IsEmpty() then + exit; + + ImportExportDialog.Caption('Export Dialog'); + if not (ImportExportDialog.RunModal() in [Action::OK, Action::LookupOK]) then + exit; + FileFormat := ImportExportDialog.GetFileFormat(); + + case FileFormat of + FileFormat::JSON: + ExportJSON(DataEditorBuffer, FieldIdsToExport); + FileFormat::Excel: + ExportExcel(DataEditorBuffer, FieldIdsToExport); + end; + end; + + local procedure ExportExcel(var DataEditorBuffer: Record "DET Data Editor Buffer"; FieldIdsToExport: List of [Integer]) + var + TempExcelBuffer: Record "Excel Buffer" temporary; TempBlob: Codeunit "Temp Blob"; RecRef: RecordRef; - JArray: JsonArray; - JObjectRoot: JsonObject; InStreamVar: InStream; OutStreamVar: OutStream; FileName: Text; begin - if DataEditorBuffer.IsEmpty() then - exit; + if DataEditorBuffer.FindSet() then begin + RecRef.Open(DataEditorBuffer."Source Record ID".TableNo()); + RecRef.ReadIsolation := RecRef.ReadIsolation::ReadCommitted; + + CreateExcelHeader(RecRef, TempExcelBuffer, FieldIdsToExport); + + repeat + RecRef.Get(DataEditorBuffer."Source Record ID"); + CreateExcelRow(RecRef, TempExcelBuffer, FieldIdsToExport); + until DataEditorBuffer.Next() = 0; + end; + + FileName := StrSubstNo(FileNameLbl, RecRef.Caption(), + Format(CurrentDateTime, 0, '--_..'), 'xlsx'); + + RecRef.Close(); + + TempBlob.CreateInStream(InStreamVar); + TempBlob.CreateOutStream(OutStreamVar); + TempExcelBuffer.CreateNewBook('Data'); + TempExcelBuffer.WriteSheet('Data', CompanyName(), UserId()); + TempExcelBuffer.CloseBook(); + TempExcelBuffer.SetFriendlyFilename(FileName); + TempExcelBuffer.SaveToStream(OutStreamVar, true); + + DownloadFromStream(InStreamVar, '', '', '', FileName); + end; + + local procedure CreateExcelHeader(var RecRef: RecordRef; var TempExcelBuffer: Record "Excel Buffer" temporary; FieldIdsToExport: List of [Integer]) + var + FieldRefVar: FieldRef; + i: Integer; + begin + TempExcelBuffer.NewRow(); + TempExcelBuffer.AddColumn('Table Number', false, '', true, false, false, '', TempExcelBuffer."Cell Type"::Text); + TempExcelBuffer.AddColumn(RecRef.Number(), false, '', false, false, false, '', TempExcelBuffer."Cell Type"::Text); + + TempExcelBuffer.NewRow(); + TempExcelBuffer.AddColumn('Table Name', false, '', true, false, false, '', TempExcelBuffer."Cell Type"::Text); + TempExcelBuffer.AddColumn(RecRef.Name(), false, '', false, false, false, '', TempExcelBuffer."Cell Type"::Text); + TempExcelBuffer.NewRow(); + + for i := 1 to RecRef.FieldCount() do begin + FieldRefVar := RecRef.FieldIndex(i); + if FieldIdsToExport.Contains(FieldRefVar.Number()) then + if (FieldRefVar.Class = FieldClass::Normal) and not (FieldRefVar.Type in [FieldType::Blob, FieldType::Media, FieldType::MediaSet]) then + TempExcelBuffer.AddColumn(FieldRefVar.Name(), false, '', true, false, true, '', TempExcelBuffer."Cell Type"::Text); + end; + end; + + local procedure CreateExcelRow(var RecRef: RecordRef; var TempExcelBuffer: Record "Excel Buffer" temporary; FieldIdsToExport: List of [Integer]) + var + FieldRefVar: FieldRef; + i: Integer; + begin + TempExcelBuffer.NewRow(); + + for i := 1 to RecRef.FieldCount() do begin + FieldRefVar := RecRef.FieldIndex(i); + if FieldIdsToExport.Contains(FieldRefVar.Number()) then + if (FieldRefVar.Class = FieldClass::Normal) and not (FieldRefVar.Type in [FieldType::Blob, FieldType::Media, FieldType::MediaSet]) then + case FieldRefVar.Type() of + FieldRefVar.Type::Option: + TempExcelBuffer.AddColumn(FieldRefVar.OptionMembers.Split(',').IndexOf(FieldRefVar.Value) - 1, + false, '', false, false, false, '', TempExcelBuffer."Cell Type"::Number); + FieldRefVar.Type::Integer, FieldRefVar.Type::BigInteger, FieldRefVar.Type::Decimal, FieldRefVar.Type::Boolean: + TempExcelBuffer.AddColumn(FieldRefVar.Value(), false, '', false, false, false, '', TempExcelBuffer."Cell Type"::Number); + FieldRefVar.Type::Date, FieldRefVar.Type::DateTime: + TempExcelBuffer.AddColumn(FieldRefVar.Value(), false, '', false, false, false, '', TempExcelBuffer."Cell Type"::Date); + FieldRefVar.Type::Time: + TempExcelBuffer.AddColumn(FieldRefVar.Value(), false, '', false, false, false, '', TempExcelBuffer."Cell Type"::Time); + else + TempExcelBuffer.AddColumn(FieldRefVar.Value(), false, '', false, false, false, '', TempExcelBuffer."Cell Type"::Text); + end; + end; + end; + + local procedure ExportJSON(var DataEditorBuffer: Record "DET Data Editor Buffer"; FieldIdsToExport: List of [Integer]) + var + TempBlob: Codeunit "Temp Blob"; + RecRef: RecordRef; + JObjectRoot: JsonObject; + JArray: JsonArray; + InStreamVar: InStream; + OutStreamVar: OutStream; + FileName: Text; + begin if DataEditorBuffer.FindSet() then begin RecRef.Open(DataEditorBuffer."Source Record ID".TableNo()); RecRef.ReadIsolation := RecRef.ReadIsolation::ReadCommitted; @@ -413,7 +672,8 @@ codeunit 81001 "DET Data Editor Mgt." JObjectRoot.Add(Format(RecRef.Number()), JArray); - FileName := StrSubstNo(FileNameLbl, RecRef.Caption(), Format(CurrentDateTime, 0, '--_..'), 'json'); + FileName := StrSubstNo(FileNameLbl, RecRef.Caption(), + Format(CurrentDateTime, 0, '--_..'), 'json'); RecRef.Close(); @@ -594,4 +854,5 @@ codeunit 81001 "DET Data Editor Mgt." LogNumberSequenceLbl: Label 'DETNSqwerty', Locked = true; FileNameLbl: Label '%1_%2.%3', Locked = true; JSONFilterLbl: Label 'JSON files (*.json, *.txt)|*.json;*.txt', Locked = true; + ExcelFilterLbl: Label 'Excel files (*.xlsx)|*.xlsx', Locked = true; } \ No newline at end of file diff --git a/Enums/Enum81002.DETFileFormat.al b/Enums/Enum81002.DETFileFormat.al new file mode 100644 index 0000000..122e3ea --- /dev/null +++ b/Enums/Enum81002.DETFileFormat.al @@ -0,0 +1,13 @@ +enum 81002 "DET File Format" +{ + Extensible = true; + + value(0; JSON) + { + Caption = 'JSON'; + } + value(1; Excel) + { + Caption = 'Excel'; + } +} diff --git a/Pages/Pag81000.DETDataEditorBuffer.al b/Pages/Pag81000.DETDataEditorBuffer.al index a7551a9..201fbb6 100644 --- a/Pages/Pag81000.DETDataEditorBuffer.al +++ b/Pages/Pag81000.DETDataEditorBuffer.al @@ -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; @@ -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, @@ -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, @@ -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 @@ -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 diff --git a/Pages/Pag81007.DETFindandReplace.al b/Pages/Pag81007.DETFindandReplace.al index f4bdd27..2b4e5ba 100644 --- a/Pages/Pag81007.DETFindandReplace.al +++ b/Pages/Pag81007.DETFindandReplace.al @@ -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, @@ -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 diff --git a/Pages/Pag81011.DETImportExportDialog.al b/Pages/Pag81011.DETImportExportDialog.al index 8a986be..2b2ca35 100644 --- a/Pages/Pag81011.DETImportExportDialog.al +++ b/Pages/Pag81011.DETImportExportDialog.al @@ -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"; } diff --git a/Translations/Data Editor Tool.g.xlf b/Translations/Data Editor Tool.g.xlf index a4725cb..2d4d40d 100644 --- a/Translations/Data Editor Tool.g.xlf +++ b/Translations/Data Editor Tool.g.xlf @@ -4683,6 +4683,16 @@ Page DET Import/Export Dialog - Property Caption + + File Format + + Page DET Import/Export Dialog - Control FileFormat - Property ToolTip + + + File Format + + Page DET Import/Export Dialog - Control FileFormat - Property Caption + Action to do when imported record is already exist in database @@ -4953,6 +4963,16 @@ Page DET Select Fields - Action Set Included - Property Caption + + Excel + + Enum DET File Format - EnumValue Excel - Property Caption + + + JSON + + Enum DET File Format - EnumValue JSON - Property Caption + Error diff --git a/Volodymyr Dvernytskyi_Data Editor Tool_3.0.0.0.app b/Volodymyr Dvernytskyi_Data Editor Tool_3.0.0.0.app deleted file mode 100644 index 02919b6..0000000 Binary files a/Volodymyr Dvernytskyi_Data Editor Tool_3.0.0.0.app and /dev/null differ diff --git a/Volodymyr Dvernytskyi_Data Editor Tool_3.0.0.2.app b/Volodymyr Dvernytskyi_Data Editor Tool_3.0.0.2.app new file mode 100644 index 0000000..68ee185 Binary files /dev/null and b/Volodymyr Dvernytskyi_Data Editor Tool_3.0.0.2.app differ diff --git a/Volodymyr Dvernytskyi_Data Editor Tool_Latest.app b/Volodymyr Dvernytskyi_Data Editor Tool_Latest.app index 02919b6..68ee185 100644 Binary files a/Volodymyr Dvernytskyi_Data Editor Tool_Latest.app and b/Volodymyr Dvernytskyi_Data Editor Tool_Latest.app differ diff --git a/app.json b/app.json index ec06ad2..886126d 100644 --- a/app.json +++ b/app.json @@ -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/", @@ -21,7 +21,7 @@ } ], "contextSensitiveHelpUrl": "https://vld-nav.com/", - "runtime": "13.0", + "runtime": "12.2", "features": ["TranslationFile"], "resourceExposurePolicy": {