ALD, ALDImport, Automation, AX, AX 2012, AX Import, AX Label, Build Scripts, Dynamics AX, PowerShell
The Import-AXLabelFile PowerShell function allows you to import an AX label file into an environment. While getting this function ready for the post, I realized that I had made a mistake in an earlier post. My current build process was built to handle one layer and one model. That was all I needed at the time and I had a limited amount of time to get it up and running. It was always my plan to make this more generic however and to do that I needed to make my functions and build process able to work for multiple layers and models. This required a few changes.
I needed a way to support what model is opened in AX for both this function and the Import-AXXPO function. I have done that using the Model parameter. Using the ConfigFile parameter to control layer and the Model file to control the model in that layer, individual calls have the ability to control the startup model versus using the “Startup model” system parameter that I had been using. I have updated both the Start-AXAutoRun and Import-AXXPO functions to support this parameter as well as the blog posts regarding these functions.
The Start-AXAutoRun function takes between 5 and 8 parameters
- ConfigPath (Client configuration for the chosen AX environment)
- Model (The AX model to open in)
- LabelFile (The label file to import)
- Timeout (The value defaults to 10 minutes but can be overridden if desired)
- SMTPServer (SMTP server to use to send the email)
- MailMsg (Net.Mail.MailMessage object used to send the email)
- AXVersion (The AX version. It defaults to 6.)
- VariablePath (Path to a file used to default the parameters/variables)
This function can be found in Codeplex. The steps of this function are:
- Load the variables if a VariablePath parameter is used
- Validate the LabelFile parameter location
- Start the AX client using the aldimport startup command
- Wait for the timeout period for the AX client to exit
- Send the success/fail message
This function is extremely similar to the Start-AXAutoRun function. There are multiple commands to use to start AX and while AutoRun can do multiple things, it can’t import label files. It is possible to reduce code duplication by dropping the Start-AXAutoRun function and replacing it with a very similar function that takes a command parameter for the AX -startupcmd parameter but I haven’t done that yet. I hadn’t previously had a function for importing label files. I was just doing this with a few lines of code in my build process. Just one of the perils of building this weekly in my spare time. Optimization through iteration.
Pingback: D2DDynamics custom PowerShell module | Day 2 Day Dynamics
Pingback: Build-AXModel custom PowerShell function | Day 2 Day Dynamics