Skip to content

Commit

Permalink
Adds Environment column to exported data
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasRuud authored and y0m0 committed Apr 29, 2024
1 parent cd7a054 commit 6504871
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
11 changes: 11 additions & 0 deletions businessCentral/app/src/CDMUtil.Codeunit.al
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ codeunit 82566 "ADLSE CDM Util" // Refer Common Data Model https://docs.microsof
BlankArray: JsonArray;
CompanyFieldNameLbl: Label '$Company';
DeliveredDateTimeFieldNameLbl: Label '$DeliveredDateTime';
EnvironmentFieldNameLbl: Label '$Environment';
ExistingFieldCannotBeRemovedErr: Label 'The field %1 in the entity %2 is already present in the data lake and cannot be removed.', Comment = '%1: field name, %2: entity name';
FieldDataTypeCannotBeChangedErr: Label 'The data type for the field %1 in the entity %2 cannot be changed.', Comment = '%1: field name, %2: entity name';
RepresentsTableTxt: Label 'Represents the table %1', Comment = '%1: table caption';
Expand Down Expand Up @@ -139,18 +140,28 @@ codeunit 82566 "ADLSE CDM Util" // Refer Common Data Model https://docs.microsof
Result.Add(
CreateAttributeJson(GetDeliveredDateTimeFieldName(), DataFormat, GetDeliveredDateTimeFieldName(), AppliedTraits, FieldRef.Length));
end;

if ADLSEUtil.IsTablePerCompany(TableID) then begin
GetCDMAttributeDetails(FieldType::Text, DataFormat, AppliedTraits);
Result.Add(
CreateAttributeJson(GetCompanyFieldName(), DataFormat, GetCompanyFieldName(), AppliedTraits, FieldRef.Length));
end;

GetCDMAttributeDetails(FieldType::Text, DataFormat, AppliedTraits);
Result.Add(
CreateAttributeJson(GetEnvironmentFieldName(), DataFormat, GetEnvironmentFieldName(), AppliedTraits, FieldRef.Length));
end;

procedure GetCompanyFieldName(): Text
begin
exit(CompanyFieldNameLbl);
end;

procedure GetEnvironmentFieldName(): Text
begin
exit(EnvironmentFieldNameLbl);
end;

procedure GetDeliveredDateTimeFieldName(): Text
begin
exit(DeliveredDateTimeFieldNameLbl);
Expand Down
17 changes: 17 additions & 0 deletions businessCentral/app/src/Util.Codeunit.al
Original file line number Diff line number Diff line change
Expand Up @@ -334,11 +334,17 @@ codeunit 82564 "ADLSE Util"
end;
if IsTablePerCompany(RecordRef.Number) then
Payload.Append(StrSubstNo(CommaPrefixedTok, ADLSECDMUtil.GetCompanyFieldName()));

Payload.Append(StrSubstNo(CommaPrefixedTok, ADLSECDMUtil.GetEnvironmentFieldName()));

ADLSESetup.GetSingleton();
if ADLSESetup."Delivered DateTime" then
Payload.Append(StrSubstNo(CommaPrefixedTok, ADLSECDMUtil.GetDeliveredDateTimeFieldName()));


Payload.AppendLine();
RecordPayload := Payload.ToText();

end;

procedure CreateCsvPayload(RecordRef: RecordRef; FieldIdList: List of [Integer]; AddHeaders: Boolean) RecordPayload: Text
Expand Down Expand Up @@ -371,13 +377,24 @@ codeunit 82564 "ADLSE Util"
end;
if IsTablePerCompany(RecordRef.Number) then
Payload.Append(StrSubstNo(CommaPrefixedTok, ConvertStringToText(CompanyName())));

Payload.Append(StrSubstNo(CommaPrefixedTok, ConvertStringToText(EnvironmentName())));

if ADLSESetup."Delivered DateTime" then
Payload.Append(StrSubstNo(CommaPrefixedTok, ConvertDateTimeToText(CurrDateTime)));

Payload.AppendLine();

RecordPayload := Payload.ToText();
end;

procedure EnvironmentName(): Text
var
EnvironmentInformation: Codeunit "Environment Information";
begin
exit(EnvironmentInformation.GetEnvironmentName());
end;

procedure IsTablePerCompany(TableID: Integer): Boolean
var
TableMetadata: Record "Table Metadata";
Expand Down

0 comments on commit 6504871

Please sign in to comment.