Requirements
- To be able to select the following fields as a dropdown, preferably a lookup. Fields: District, City and Country because the District and City list may continue to expand in the future.
- To be able to add multiple addresses against the Account. 2 or more.
- In case we need to update an address, there must be a provision in the Address table to select the District, City and Country as well. i.e., these fields must be available in the Address table as lookup fields.
These requirements sound simple to implement, however the address entity lacks flexibility due to which we had to think of a workaround.
Things I have learnt about Addresses
- On the Account we can add maximum 2 addresses. Address 1 and Address 2. Let's call this embedded address. If we need to add a 3rd address related to an account, we need to create a new address record (in the related system Address table).
- While the Country and State fields are available, these are text fields in the embedded address and related system address table.
- The related address table is non-customizable. We cannot add additional lookup fields in that entity.
- When an Account or Contact record is created, blank Address records are automatically created and linked to the Account (or Contact). These are associated with the embedded address records and are numbered as "addressnumber" 1 and 2. addressnumber 1 represents invoice address and 2 represents delivery address by default.
- The system Address tables don't have lookup to Account or Contact. The relationship is identified by 2 fields namely, "objecttypecode" and "parentid". objecttypecode recoginzes if this related address is linked to "Account" or "Contact" and parentid is the actual GUID value of the Account or Contact.
Workaround to address the limitations
Since the system Address entity is linked and tightly integrated in Dynamics 365 CE, we couldn't replace the system Address table with new custom Address table. I am saying this because, system Address primarily linked to Account and Contact, but when we update the address on Lead and qualify it, the embedded Address and correspondingly the system Address records are also updated. Also, indirectly linked with Opportunities, Quotes and beyond. If you're considering dual write integration with Dynamics 365 F&O, these are again tightly integrated there.
Having analyzed this, we went ahead with a custom Address entity but ensured we are keeping the system Address entity records in sync as well.
What did we do?
- We created 3 custom lookup fields called District, City and Country on the Lead, Account and Contact tables for easy data entry from users perspective. When the user selects these fields, we populate the OOB District, State and Country text fields and those are automatically updated in the related system address records.
- We introduced a custom address entity and ensured the user uses this for their data entry and viewing. When the user updates the embedded address, we also need to create custom address records related to Account.
- When the custom address records are updated, we need to update the related system address entity records.
- When a new custom address is created, we create a related system address entity record and link it with the respect Account by updating the objecttypecode and parentid.
- When the custom address is deleted, we need to also delete the related system address record and update the embedded addresses if the addressnumber matches. By update I mean we had to clear the values in the embedded address fields on the Account record.
- For the most part we can treat system Addresses as a target only, as they are a copy of the custom Address entity data. We can set up a business process and data entry process in such a way that system addresses are not updated, however, if some process we don’t know about updates a system Address, it needs to get reflected up to the custom Address as well.
Hope that helps!
No comments:
Post a Comment