Skip to main content

Merge objects

#-------------------------------PRE STEP------------------------------- 
#The files need to be named ORIGINAL, MODIFIED, TARGET + the selected identifier

$ApplicationObjectFile = "";
$ModifiedIdentifier = "";
$OriginalIdentifier = "";
$TargetIdentifier = ""

$PathForMicrosoftDynamicsNavManagement = "";
$PathForMicrosoftDynamicsNavModelTools = "";

#-------------------------------DO NOT EDIT UNDER THIS LINE-------------------------------

Import-Module $PathForMicrosoftDynamicsNavManagement
Import-Module $PathForMicrosoftDynamicsNavModelTools -DisableNameChecking

$Delta = "DELTA";
$Modified = "MODIFIED" + $ModifiedIdentifier;
$Original = "ORIGINAL" + $OriginalIdentifier;
$Target = "TARGET" + $TargetIdentifier;
$Result = "RESULT";

#----- Folder creation ----- START
$DeltaPath = $ApplicationObjectFile + $Delta;
if (!(Test-Path $DeltaPath)) {
New-Item -ItemType directory -Path $DeltaPath;
}
$DeltaPath += "\";

$ResultPath = $ApplicationObjectFile + $Result;
if (!(Test-Path $ResultPath)) {
New-Item -ItemType directory -Path $ResultPath;
}
$ResultPath += "\";

$TargetPath = $ApplicationObjectFile + $Target;
if (!(Test-Path $TargetPath)) {
New-Item -ItemType directory -Path $TargetPath;
}
$TargetPath += "\";

$ModifiedPath = $ApplicationObjectFile + $Modified;
if (!(Test-Path $ModifiedPath)) {
New-Item -ItemType directory -Path $ModifiedPath;
}
$ModifiedPath += "\";

$OriginalPath = $ApplicationObjectFile + $Original;
if (!(Test-Path $OriginalPath)) {
New-Item -ItemType directory -Path $OriginalPath;
}
$OriginalPath += "\";
#----- Folder creation ----- FINISH

$ModifiedFile = $ApplicationObjectFile + $Modified + ".txt";
Split-NAVApplicationObjectFile -Source $ModifiedFile -Destination $ModifiedPath -PreserveFormatting;

$OriginalFile = $ApplicationObjectFile + $Original + ".txt";
Split-NAVApplicationObjectFile -Source $OriginalFile -Destination $OriginalPath -PreserveFormatting;

$TargetFile = $ApplicationObjectFile + $Target + ".txt";
Split-NAVApplicationObjectFile -Source $TargetFile -Destination $TargetPath -PreserveFormatting;

Merge-NAVApplicationObject -ModifiedPath $ModifiedPath -OriginalPath $OriginalPath -ResultPath $ResultPath -TargetPath $TargetPath