February 27, 2017

How to add Standard Address fields into a new table [Dynamics365/AX7]

Hi Folks,

Its been a long time to write any new post on AX. Here I’m back today. Since few months we all are trying the new Dynamics 365 and its amazing new features in D365.

In this post we will see how to add new address fields in table using Table mapping.

[Note: In D365 we have object extension functionality to customize standard objects. But we don't have this option for Maps. This post will also help you to understand the alternative for the same by using table Mapping section.]

Requirement: We need to add all standard address fields in table followed by adding a new tab for address in respective from.

Proposed solution: We can achieve this by adding a single field rather than add multiple fields in table. Perform below steps to get this done,

1. Add a new field in table, EDT type “LogisticsLocationRecId”, rename it  as “Location”.

2. Now add a new Foreign key relation for “LogisticPostalAddress”  table and set its property as below snap shot,

image

3. Add a new map in mapping node for “LogisticsLocationMap”. Map field to location.
Your table must looks like below

image

Now we done with table customization, now we need do some addition on Form.

4. Firstly, Add new DS in your form, Table : “LogisticsPostalAddress”, set “LinkType” as “OuterJoin” with your main DS (where we added our new field “Location”)

5. Add a new tab page into your design with DS “LogisticsPostalAddress”(make sure it will be as per your from pattern)

image

Set Menu item object for menu item button as below table
MenuItemButton MenuItem Object Name
NewAddress LogisticsPostalAddressNewCustBankAccount
EditAddress LogisticsPostalAddressEditCustBankAccoun
ClearAddress LogisticsPostalAddressClearCustBankAccou
MapButton LogisticsPostalAddressMap

6. Add below code
I. Form declation 
LogisticsPostalAddressFormHandler   addressController; 
II. Form init
public void init()
    {
        super();

        addressController = LogisticsPostalAddressFormHandler::newParameters(<maintable>_ds,LogisticsPostalAddress_ds);
        addressController.callerUpdateQuery(fieldNum(<maintable>,Location));
    }
 
III. New global method
public LogisticsPostalAddressFormHandler getAddressController()
    {
        return addressController;
    }
 
IV. Active method of new DS (LogisticsPostalAddress)
public int active()
        {
            int ret;
       
            ret = super();

            addressController.callerActive();
            addressController.callerUpdateButtons(newAddress,editAddress,clearAddress,mapButton);
       
            return ret;
        }
7.Save all your changes, build project and run the Form. Your changes must looks like below,
New tab on from
image
while click on edit button you will get an dialog that contain all address fields.

image

You can make require changes and click on Ok button it will save your changes and on Form will show complete address  in a single field (LogisticsPostalAddress.address)

Hope it will help…, Please keep sharing your comments and feedback.

-Harry

October 02, 2016

How to deploy a Package [AX7]

Hi Folks,

[Make sure you will run every application as admin]

I hope many of us already moved on Next version of Dynamics AX. Today I am going to demonstrate “How to Deploy a Package in AX7”. In current version, we have new architecture for code deployment. Now we don’t have the option for ad hoc import, like we did using XPO export import. Now AX is very different in terms of deployment, code movement and build etc, Please refer this post for more details this architecture.
Every customization must be moved using deployable package from one environment to another. There two ways to move this package on target environment.

Check below link for meta data hotfix,
How deploy a metadata or X++ hotfix [D365FO]


A. Using LCS services.
B. Manual using command prompt.

Here I’ll show using command prompt, as I found its better than LCS (After successfully deploy many packages J)
Follow below steps,
clip_image002

1. Create Deployment Package:
Run VS as admin, Go to Dynamics AX menu. Select Create a deployment package as shown below.

clip_image003

Choose your package from list and path to save this file
image

Click on create.
It will take few minutes to complete this process.

2. Upload on LCS shared library:
However, we are not using LCS in this demo, but it’s always a good practice to maintain all deployment package on LCS. You can use this library to deploy this package to any environment that is part of your project.
Upload this file to LCS, shared asset library> S/w deployable package

clip_image007

Click on + button, Fill the details, select the package

clip_image008

Add file and, upload the same.

clip_image009

After upload done, click on confirm.

3. Open Other environment (RDP).

4. Copy this package to this box (Download this package from LCS there. OR copy paste there).

5. Now, first right click on zip file, unlock this. Expend it.

Now run this command for all child folders, unlock this zip file using PowerShell command
Get-ChildItem C:\Users\axlocaladmin\Downloads\ AXDeployablePackage_20160923_05_36_14-recurse | Unblock-File –Confirm

clip_image011

6. Generate runbook for this package.
    a. Open command prompt as administrator
    b. Navigate to your package folder
    c. Run below command
On any VM, run the following command to generate the runbook.
AXUpdateInstaller.exe generate –runbookid=[runbookID] –topologyfile=[topologyFile] –servicemodelfile=[serviceModelFile] –runbookfile=[runbookFile]
Here is an explanation of the parameters that are used in this command:
      i. [runbookID] – A parameter that is specified by the developer who applies the deployable package
      ii. [topologyFile] – The path of the DefaultTopologyData.xml file
      iii. [serviceModelFile] – The path of the DefaultServiceModelData.xml file
      iv. [runbookFile] – The name of the runbook file to generate (for example, AOSRunbook.xml)

Example
AXUpdateInstaller.exe generate -runbookid=" AXDeployablePackage_20160923_05_36_14-runbook" -topologyfile="DefaultTopologyData.xml" -servicemodelfile="DefaultServiceModelData.xml" -runbookfile=" AXDeployablePackage_20160923_05_36_14-runbook.xml"
The runbook provides the sequence of steps that must be run to update the environment. The following illustration shows an example of a runbook file. Each step in a runbook is associated with an ID, a machine name, and step execution details.
Sometimes runbook id will not generated correctly, so you have to manually update the same in runbook file. Simply copy your folder name and out it as runbook id in xml file.

clip_image013
This process will generate a runbook xml file into package folder.

7. Import the runbook by running the following command.
AXUpdateInstaller.exe import -runbookfile=[runbookFile]

Example
AXUpdateInstaller.exe import -runbookfile=" AXDeployablePackage_20160923_05_36_14-runbook.xml"
clip_image015

8. Verify the runbook.
AXUpdateInstaller.exe list
clip_image017
  1. Execute the runbook.
AXUpdateInstaller.exe execute -runbookid=[runbookID]
Example
AXUpdateInstaller.exe execute -runbookid=" AXDeployablePackage_20160923_05_36_14-runbook"
  1. Export the runbook.
AXUpdateInstaller.exe export -runbookid=[runbookID] -runbookfile=[runbookFile]

Example
AXUpdateInstaller.exe export -runbookid="VAL200AA2BMEDIU-runbook" -runbookfile="VAL200AA2BMEDIU-runbook.xml"
AXUpdateInstaller updates the runbook file after each step is run on a VM. The runbook also logs information about each step.
clip_image019


Troubleshooting:

1. Sometimes you will get some issue on execution, so it’s better to rename the package folder and use old name in runbook.
For eg: If your package file name is like “AXDeployablePackage_20160923_05_36_14” Than you have to rename this folder as “AXDeployablePackage”. Now unlock this folder using PowerShell and try with further steps.

2. For more detail check below links.
https://ax.help.dynamics.com/en/wiki/installing-deployable-package-in-ax7/

-Harry

October 01, 2016

Fourth time in a row

Hi All, 

After a hattrick, it’s my fourth time in a row.  Thanks to each of you for your and support.   


Old Post:

-Deepak Agarwal aka Harry 


Follow us on Facebook to keep in rhythm with us. @Facebook https://www.facebook.com/theaxapta