Yesterday, I got a question that I found was too difficult to answer: “What tables were added in 20.5?”
The reason for this question was simple: we need to update the manually created permissionsets in order for new tables to be supported after an upgrade. So – what tables were added?
There are a number of ways to deal with this, like exporting the AllObj-table from both versions, and do some kind of VLOOKUP in excel. I didn’t want to spend those 10 minutes to do that. I wanted to spend a few hours in creating a PowerShell script 🤪.
And here is the result:
$Sourcebranch = 'be-19'
$Targetbranch = 'be-20'
$ForcePull = $false
$ObjectType = 'Table'
set-location "C:\_source\MSDyn365BC.Code.History"
$ObjectPattern = '(ObjectType) +([0-9]+) +("[^"]*"|[\w]*)([^"\n]*"[^"\n]*)?'
if ($ObjectType){
$ObjectPattern = $ObjectPattern -replace "ObjectType", $ObjectType
} else {
$ObjectPattern = $ObjectPattern -replace "ObjectType", 'codeunit|page|pagecustomization|pageextension|reportextension|permissionset|permissionsetextension|profile|query|report|requestpage|table|tableextension|xmlport|enum|enumextension|controladdin|interface|interface|entitlement|controladdin'
}
if ($ForcePull){
& git config diff.renameLimit 999999
& git checkout $SourceBranch
& git prune
& git pull
& git checkout $TargetBranch
& git prune
& git pull
& git checkout master
& git prune
}
$AllObjects = . git diff $SourceBranch $TargetBranch --diff-filter=A --name-only
if ($ObjectType){
$SelectString = ".*(\.$ObjectType).al"
} else {
$SelectString = ".*.al"
}
$AllObjects | Select-String $SelectString | ForEach-Object {
$CurrObj = $_
$MatchingLines = Get-Content $CurrObj | Select-String $ObjectPattern
if($MatchingLines){
$MatchingLines = $MatchingLines.ToString();
$IsTemp = Get-Content $CurrObj | Select-String "TableType = Temporary"
if ($IsTemp){
$MatchingLines += " *** TEMP ***"
}
Write-Host $MatchingLines -ForegroundColor Green
} else {
Write-Host $CurrObj -ForegroundColor Yellow
}
}
It absolutely isn’t anything special – and probably there are better ways to do this (I used to be faster with PowerShell – I’m clearly getting old 😱). I just wanted to share the script should anyone be interested 🤷♂️.
A few words of explanation:
- This script uses the great repo from Stefan Maron, which you can find here. It contains all the necessary info I need: all added files between certain commits or branches.
- On top of the script, you can set some parameters, like:
- branch-names you’d like to compare
- What object type you’re interested in (leave empty for all)
- If you’d like to force pulling all commits from these branches
- The local path to the Stefan’s repository
- It uses some git-commands to pull (or update) the branches. Probably many improvements could be made here – but I didn’t care too much, as long as I got my result 🤪.
- It is going to use
git diff
to get the differences between two branches (or commits) - The files of that output are being parsed to get more interesting info: object type, id, and name – if possible (many improvements can be made in this directions)
When you successfully ran the script, you simply get a list of objects:
Enjoy – and have a nice weekend!
4 comments
2 pings
Skip to comment form
Hi sir. It looks like the link to Stefan Maron repos does not work (maybe just for me?). I was able to find the repos (thanks Google) but thought I’d let you know.
Author
Thanks so much for mentioning – I corrected it!
VLOOKUP is old and outdated, you should use XLOOKUP instead and save a few seconds. 🙂
Author
🤣😂
[…] What objects were added? […]
[…] Source : Waldo’s Blog Read more… […]