Simplifying Dynamics 365 Custom Model Renaming with PowerShell
Simplifying Dynamics 365 Custom Model Renaming
with PowerShell
Introduction: Renaming components within a custom Dynamics 365 (D365) model can be a daunting task. From adjusting naming conventions to updating properties and label files, the process often involves meticulous manual effort. However, with the power of PowerShell scripts, this challenge can be tackled efficiently and effectively. Let's explore how PowerShell can streamline the renaming process, saving time and reducing errors.
Identifying the Challenge: In many scenarios, businesses find themselves needing to update the naming convention of their custom D365 model to reuse with other specified convention. This could be due to rebranding, restructuring, or simply refining organizational standards. Regardless of the reason, the task entails modifying prefixes across various artifacts within different object types. Additionally, properties, label files, and label IDs must be updated accordingly. Such a comprehensive renaming endeavor can quickly become overwhelming without the right approach.
The Power of PowerShell: Fortunately, PowerShell comes for the developers to the rescue. Its versatility and scripting capabilities make it an ideal tool for handling complex renaming tasks with ease. By leveraging PowerShell scripts tailored to your specific requirements, you can execute the renaming process swiftly and accurately.
Streamlining the Renaming Process: Let's delve into the key steps involved in using PowerShell to streamline the renaming process for your custom D365 model:
Existing
Model name: ABC_CustomizationsSuite
Current artifacts
prefix: ABC_
Model Name
to be: XYZ_CustomizationsSuite
Artifacts
prefix should replace with: XYZ_
- Rename the main model folder within AOS service packages local
directory from ABC_CustomizationsSuite to XYZ_CustomizationsSuite.
- Open the windows powershell as administrator.
- Change the directory to your model folder.
Ø cd ‘C:\AOSService\PackagesLocalDirectory\XYZ_CustomizationsSuite’
- Run below commands to get the all xml files from the specific file
path, update the prefix for all artifacts within each object type and
update the model name in all extensions.
Ø $filePath = " C:\AOSService\PackagesLocalDirectory\
XYZ_CustomizationsSuite\*.xml"
Ø Get-ChildItem
$filePath -Recurse | ForEach-Object {
Rename-Item
-Path $_.PSPath -NewName $_.Name.replace("ABC_","XYZ_")
Rename-Item
-Path $_.PSPath -NewName $_.Name.replace(".ABC_CustomizationsSuite "," .XYZ_CustomizationsSuite ")
}
- Now run the following command to
retrieve and update the content of files within the folder. This action
will modify the label IDs and content utilized in classes or other objects
with the previous naming convention.
Ø Get-ChildItem $filePath
-Recurse | ForEach-Object {
(Get-Content
$_).Replace('ABC_','XYZ_') | Set-Content $_
(Get-Content
$_).Replace('@ABC_CustomizationsSuite','@XYZ_SaleCustomizationSuite') |
Set-Content $_
(Get-Content $_).Replace('.ABC_CustomizationsSuite','.XYZ_SaleCustomizationSuite') | Set-Content $_
}
You have accomplished the renaming of your model's naming convention successfully. Verify the artifacts to confirm that all have been renamed as intended. Next, proceed with building and synchronizing the model, and then enjoy the time you've saved!
Comments
Post a Comment