March 09, 2017

How to rename an Object in VisualStudio[Dynamics365/AX7]

Hi Folks,
Many times we need to duplicate an standard object and do the required changes and system gives warning while rename. Same caused error during project build.
 Problem: While renaming any object in Visual studio project system throw below warning
“Some of the files you are renaming or moving will be located outside of the project's binding root. The item(s) <objectName>.xml will not be source controlled if you continue with this rename.”
image
If you just continue with change , you may get errors while project/solution build.
Possible reason: If you are using TFS and this new object are not added to source code you’' will get this error.
Suggest Solution: Add this new object in Source control by right click on object and select “Add file  to source control”
image
Now you should be able to rename it.
This works for me perfectly. If you got some other solution to fix this issue plz keep share your feedback or links to other posts.
-Harry

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