Pages

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

7 comments:

  1. thank you very much for all this informations, can you plz explain to me how do that in dynamix ax 2012 r2

    ReplyDelete
    Replies
    1. Hi Casa, I would suggest try to follow same steps in AX2012. If you get any errors there i can help to troubleshoot.

      Delete
  2. Thank you very much for the great post, is it possible to achieve the same result in standard forms in D365?

    ReplyDelete
    Replies
    1. Your welcome, I didnt get your question. Can you please share more details what you are looking for.

      Delete
  3. That was some grate information and its was really helpful, Please keep on discovering.
    -M.AS.

    ReplyDelete
  4. I am getting an error after clearing the field.

    Location must be filled in
    country/region must be filled in

    can you help me in this.

    ReplyDelete
    Replies
    1. you need to debug your in dev box, there you must be missing some setup to be picked for country

      Delete

Thanks